CommandRunner<O extends OptionDefinition, T> constructor

CommandRunner<O extends OptionDefinition, T>(
  1. String executableName,
  2. String description, {
  3. String? invocation,
  4. String? rootFooter,
  5. List<O>? globalOptions,
  6. List<Command<OptionDefinition, T>>? subcommands,
  7. List<CommandMiddleware<O, T>>? middlewares,
  8. bool? canRunAsLeafCommand,
  9. UsageGenerator? usageGenerator,
  10. ParserSettings? parserSettings,
  11. UsageOutputHandler? usageOutput,
  12. CompletionSettings? completion,
})

Creates a new command runner with the given executable name and description.

executableName is the name of the executable being run, as presented in usage and error messages.

description is the usage description of this root command (the executable).

invocation overrides the default invocation synopsis of this root command (the executable).

rootFooter is a string that will be added to this root command's usage footer.

globalOptions is the list of global options. Global options are "persistent" which means they are valid anywhere on the command line.

subcommands is a list of subcommands that will be added to the runner. Can also be added later using addSubcommand.

middlewares is a list of middlewares that will be added to the runner.

canRunAsLeafCommand when true allows this command to run as a leaf command even if it has subcommands.

usageGenerator overrides the UsageGenerator for this root command (not its subcommands, each command has its own).

parserSettings overrides the default ParserSettings for this runner and its subcommands.

usageOutput overrides the default UsageOutputHandler for this runner and its subcommands.

completion configures the built-in shell completion support for this runner and its subcommands. See CompletionSettings.

Implementation

CommandRunner(
  this.executableName,
  final String description, {
  final String? invocation,
  final String? rootFooter,
  final List<O>? globalOptions,
  super.subcommands,
  super.middlewares,
  super.canRunAsLeafCommand,
  final UsageGenerator? usageGenerator,
  final ParserSettings? parserSettings,
  final UsageOutputHandler? usageOutput,
  final CompletionSettings? completion,
}) : usageDefinition = CommandUsageDefinition(
       description: description,
       usageFooter: rootFooter,
       invocation: invocation,
     ),
     usageOutput = usageOutput ?? UsageOutputHandler(),
     completion = completion ?? const CompletionSettings(),
     parserSettings = parserSettings ?? const ParserSettings(),
     super(
       usageGenerator: usageGenerator ?? const StandardRunnerUsageGenerator(),
       persistentOptions: globalOptions,
       builtinSubcommands: [
         if (completion?.enabled ?? true)
           CompletionCommand<T>(hidden: completion?.hideCommand ?? false),
       ],
     );