showMenu static method
Show a menu and get user selection
Implementation
static Future<int> showMenu(String title, List<String> options) async {
print('\n$title');
print('\u2500' * 40);
for (int i = 0; i < options.length; i++) {
print(' ${i + 1}. ${options[i]}');
}
print('\u2500' * 40);
stdout.write('Enter selection (1-${options.length}): ');
final input = stdin.readLineSync()?.trim();
final selection = int.tryParse(input ?? '');
if (selection == null || selection < 1 || selection > options.length) {
warn('Invalid selection, defaulting to 1');
return 0;
}
return selection - 1;
}