inject method
void
inject(
- Option option
Implementation
void inject(Option option) {
void voidCallback(_) {}
if (option.isFlag) {
addFlag(
option.name,
abbr: option.abbr,
aliases: option.aliases,
help: option.help,
callback: option.callback as _Callback? ?? voidCallback,
defaultsTo: option.defaultsTo as bool? ?? false,
hide: option.hide,
negatable: option.negatable ?? false,
);
} else if (option.isMultiple) {
addMultiOption(
option.name,
abbr: option.abbr,
aliases: option.aliases,
help: option.help,
defaultsTo: option.defaultsTo as List<String>? ?? <String>[],
hide: option.hide,
allowed: option.allowed,
allowedHelp: option.allowedHelp,
callback: option.callback as _Callback? ?? voidCallback,
splitCommas: option.splitCommas,
valueHelp: option.valueHelp,
);
} else if (option.isSingle) {
addOption(
option.name,
abbr: option.abbr,
aliases: option.aliases,
help: option.help,
defaultsTo: option.defaultsTo as String? ?? '',
hide: option.hide,
allowed: option.allowed,
allowedHelp: option.allowedHelp,
callback: option.callback as _Callback? ?? voidCallback,
valueHelp: option.valueHelp,
mandatory: option.mandatory,
);
} else {
throw Exception('Unknown option type: $option');
}
}