getMultiOption function
Implementation
List<String> getMultiOption(
ArgResults results,
String name,
String message,
List<String> options, {
required bool isInteractive,
required bool isRequired,
List<String> startingOptions = const [],
String? desc,
}) {
var value = results[name] as List<String>? ?? [];
if (!isInteractive) {
if (value.isEmpty) {
if (startingOptions.isNotEmpty) {
return startingOptions;
} else {
print('Missing parameter $name is required.');
exit(1);
}
}
}
if (value.any((e) => !options.contains(e))) {
print('Invalid value $value provided. Must be in: $options');
value = [];
}
if (desc != null) {
stdout.write(ansi.darkGray.wrap('\n$desc\u{1B}[1A\r'));
}
value = cbx(message, options, startingOptions);
if (desc != null) {
stdout.write('\r\u{1B}[K');
}
return value;
}