run method
override
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<int> run(Iterable<String> args) async {
try {
final topLevelResults = parse(args);
if (topLevelResults['verbose'] == true) {
_logger.level = Level.verbose;
}
return await runCommand(topLevelResults) ?? ExitCode.success.code;
} on FormatException catch (e, stackTrace) {
_logger
..err(e.message)
..err('$stackTrace')
..info('')
..info(usage);
return ExitCode.usage.code;
} on UsageException catch (e) {
_logger
..err(e.message)
..info('')
..info(e.usage);
return ExitCode.usage.code;
}
}