runCommandLine method

Future<T?> runCommandLine(
  1. CommandContext<O, T> contexts
)

Runs the command line: the middlewares of the commands on the command line, then the tail command or an action option.

If a command (or middleware) throws a UsageException, it is handled by usageOutput the same way as for configuration input errors.

Implementation

Future<T?> runCommandLine(final CommandContext<O, T> contexts) async {
  try {
    return await _runNested(contexts);
  } on UsageException catch (e, s) {
    // commands may implement custom usage checks and throw UsageException
    final exception = usageOutput.onUsageException(e, fromCommand: this);
    if (exception == null) return null;
    Error.throwWithStackTrace(exception, s);
  }
}