resolveConfigurations method

CommandContext<O, T>? resolveConfigurations(
  1. Iterable<String> args,
  2. Map<String, String>? env,
  3. ContextProvider provider
)

Resolves the configurations for all commands on the command line and returns the list of contexts for the commands.

On configuration input errors (including command line arguments, environment variables, and configuration files), a usage error message is printed and a UsageException is thrown. This behavior can be changed by passing a custom UsageOutputHandler on construction, for example by suppressing UsageException from being thrown in which case null is returned instead.

If null is returned, the runner returns null without running any command.

This method can be overridden by subclasses.

Implementation

CommandContext<O, T>? resolveConfigurations(
  final Iterable<String> args,
  final Map<String, String>? env,
  final ContextProvider provider,
) {
  try {
    return resolver.resolveConfigurations(
      args,
      env,
      provider,
      runMode: CommandRunMode.execution,
    );
  } on UsageException catch (e, s) {
    final exception = usageOutput.onUsageException(e, fromCommand: this);
    if (exception == null) return null;
    Error.throwWithStackTrace(exception, s);
  }
}