handleSelectModule method

Future<void> handleSelectModule(
  1. List<String> list
)

Implementation

Future<void> handleSelectModule(List<String> list) async {
  try {
    print('选择模块:');
    for (int i = 0; i < list.length; i++) {
      print('${i + 1}. ${list[i]}');
    }

    String? answer = stdin.readLineSync();
    int index = int.tryParse(answer ?? '') ?? 0;
    if (index > 0 && index <= list.length) {
      selectModule = list[index - 1];
      await getDirectories(path.join('./lib/pages', selectModule));
      await handleInputName();
    } else {
      print('无效选择');
    }
  } catch (error) {
    print('错误: $error');
  }
}