run method
Parses args
and invokes Command.run
on the chosen command.
This always returns a Future in case the command is asynchronous. The
Future will throw a UsageException
if args
was invalid.
Implementation
@override
Future<void> run(Iterable<String> args) async {
// Print version if requested.
// If no subcommand is provided, exit after printing.
final hasVersion = args.contains('--version') || args.contains('-v');
final hasSubcommand = args.any((a) => commands.containsKey(a));
if (hasVersion) {
Logger.standard().write('ℹ️ CLI version: $packageVersion\n');
if (!hasSubcommand) return;
}
return super.run(args);
}