command library

Classes

BridgeCommand<O extends OptionDefinition, T>
A bridge command that closes the gap between Command and the old args package's Command class.
Command<O extends OptionDefinition, T>
A Command is a named task on the command line. It is a "branch" command if it has subcommands, otherwise it is a "leaf" command. Leaf commands have a run method that is called when the command is executed.
CommandCompletionContext<T>
A CompletionContext that carries the command contexts resolved for the words typed so far.
CommandContext<O extends OptionDefinition, T>
The configuration context for the individual command being run.
CommandImpl<O extends OptionDefinition, T>
A parameterized implementation of Command for easy set up of a command object via parameters rather than overriding fields.
CommandMiddlewareComposer<O extends OptionDefinition, T>
Convenience class for easier type binding of MiddlewareComposer for commands.
CommandMiddlewareHooks<O extends OptionDefinition, T>
Convenience class for easier type binding of MiddlewareHooks for commands.
CommandResolver<O extends OptionDefinition, T>
Interface for the command resolver, which resolves the configurations for each command on the command line.
CommandRunner<O extends OptionDefinition, T>
A command runner for a command line application.
CompletionActionOption
CompletionCommand<T>
The built-in completion command, which prints the completion script for a shell to CompletionSettings.sinks. Its install subcommand, CompletionInstallCommand, installs the script instead.
CompletionDirective
Flags that instruct the shell how to treat the completion response.
CompletionEngine<O extends OptionDefinition, T>
Computes the completion candidates for a partial command line, using the command tree and option definitions of a root command.
CompletionInstallCommand<T>
The completion install command, which installs the completion script for the current user with a CompletionInstaller, and prints the steps of the installation to CompletionSettings.sinks.
CompletionInstaller
Installs the completion script of a shell for the current user, in the way that is the common practice for the shell:
CompletionInstallStep
A step of a completion installation: a change to the file system, or a note that a file needs no change.
CompletionPrelude
The command line state for one option-value completion.
CompletionResponse
The response to a completion request, see completeRequestCommand.
CompletionSettings
Settings for the built-in shell completion support of a CommandRunner.
ContextProvider
A type-keyed bag of values shared for one command run.
HelpActionOption
HelpCommand<T>
Standard built-in help command.
Middlewares
Convenience methods for creating CommandMiddlewares.
OptionValueCompletion<O extends OptionDefinition, T>
Completes an option value after resolving the command line typed so far.
OriginalCommandLine
OutputSinks
Output sinks for CommandRunner.
StandardCommandResolver<O extends OptionDefinition, T>
The standard command resolver.
StandardCommandUsageGenerator
StandardRunnerUsageGenerator
StandardUsageExceptionHandler
StandardUsageExceptionPrinter
The standard implementation of UsageExceptionPrinter which implements the default layout and formatting of a usage exception printed to OutputSinks.err.
UsageExceptionPrinter
Interface of a usage exception printer, which implements the layout and formatting of a usage exception printed to OutputSinks.err.
UsageExceptions
UsageExceptionSettings
///////////////////// /////////////////////
UsageGenerator
A command usage string generator.
UsageOutputHandler
The settings and behavior for the usage output - controls the help output and the usage exception output.
UsageSettings

Enums

BuiltinGlobalOption<V extends Object>
The built-in global options of a command runner, see CommandRunner.builtinPersistentOptions.
CommandRunMode
Whether a command context is being used to run or to complete the command line.
CompletionInstallOption<V extends Object>
The options of the CompletionInstallCommand.
CompletionOption<V extends Object>
The options of the CompletionCommand. They are persistent, i.e. also valid after its install subcommand.
CompletionShell
The shells and completion frameworks for which completion scripts can be generated.

Mixins

ActionOptionMixin<V>
ActionOptionMixin can be added to an option definition to make CommandRunner run it as an "action option" when it is specified on the command line.

Constants

completeRequestCommand → const String
The hidden built-in root command word that serves completion requests from the shell completion scripts.

Functions

commandContextOf<O extends OptionDefinition, T>(CompletionContext context) → CommandContext<O, T>?
The leaf CommandContext resolved for this completion, if the command runner prepared one.
completionInstallationOverview(String executableName, {bool viaOption = false, String heading = 'Installation:'}) → String
Short installation instructions for all shells, one line per shell, under a heading. Used in the usage of the completion command.
detectCompletionShell({Map<String, String>? environment, Iterable<List<String>>? ancestorCommandLines, bool? isWindows}) → CompletionShell?
Determines the shell that the user most likely runs the program from, or null if there is no such CompletionShell.
printCommandUsage(CommandContext<OptionDefinition, dynamic> context) → void
Prints the usage of the contest's command to the usage output, via the root command's UsageOutputHandler.
printCompletionScript(CommandRunner<OptionDefinition, dynamic> runner, CompletionShell shell, {String? commandName}) → Future<void>
Writes the completion script of shell for runner to CompletionSettings.sinks. See writeCompletionOutput.
requestCompletionFrom(String executable, List<String> words, {Map<String, String>? environment}) → Future<CompletionResponse>
Asks another program for the completion of words, and returns its response as it is.
shellIdentifier(String executableName) → String
A name for executableName that is safe to use in shell identifiers: letters, digits and underscores only.
shellQuote(String value) → String
value as a single-quoted string literal for POSIX shells and Fish.
shellWord(String value) → String
value as one word of a command line for POSIX shells and Fish: as it is if it is a plain word, otherwise quoted with shellQuote.
standardUsageExceptionHandler(UsageException exception, UsageOutputHandler usageOutput, {required CommandDefinition<OptionDefinition>? fromCommand}) → UsageException?
writeCompletionOutput(CommandRunner<OptionDefinition, dynamic> runner, String output) → Future<void>
Writes the completion output (a response or a script) to CompletionSettings.sinks.

Typedefs

CommandHandler<O extends OptionDefinition, T> = Handler<FutureOr<T?>, CommandContext<O, T>>
CommandMiddleware<O extends OptionDefinition, T> = Middleware<FutureOr<T?>, CommandContext<O, T>>
CommandRunFunction<O extends OptionDefinition, T> = FutureOr<T?> Function(CommandContext<O, T> context)
The type of the Command.run method.
UsageExceptionHandler = UsageException? Function(UsageException exception, UsageOutputHandler usageOutput, {required CommandDefinition<OptionDefinition>? fromCommand})
exception is typically a CommandUsageException. fromCommand is a fallback if it isn't.

Exceptions / Errors

ContextValueNotFound
Thrown when ContextProvider.fetch finds no value of the requested type.