run method

  1. @override
Future<int> run(
  1. Iterable<String> args
)
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 {
    var argResults = parse(args);
    if (argResults["verbose"] == true) {
      logger.level = Level.verbose;
    }
    failFast = argResults["fail-fast"] == true;
    useDartBinary = argResults["dart"] == true;
    return await runCommand(argResults) ?? ExitCode.success.code;
  } on FormatException catch (e) {
    logger
      ..err(e.message)
      ..info('')
      ..info(usage);
    return ExitCode.usage.code;
  } on UsageException catch (e) {
    logger
      ..err(e.message)
      ..info('')
      ..info(e.usage);
    return ExitCode.usage.code;
  } catch (error) {
    logger.err('$error');
    return ExitCode.software.code;
  }
}