BetterCommand<O extends OptionDefinition, T> class
abstract
An extension of Command with additional features.
The BetterCommand class uses the config library to provide a more enhanced command line interface for running commands and handling command line arguments, environment variables, and configuration.
Constructors
-
BetterCommand({List<
O> ? options = const [], @Deprecated('Unused, use usageOutput in BetterCommandRunner') MessageOutput? messageOutput = _defaultMessageOutput, @Deprecated('Unused, use wrapTextColumn parameter in BetterCommandRunner') int? wrapTextColumn, @Deprecated('Unused, see BetterCommandRunner') Map<String, String> ? env}) - Creates a new instance of BetterCommand.
Properties
- acceptsPartialCommandLine → bool
-
Whether this command accepts a partial command line, i.e. runs as the
last command on the command line even if the command line is incomplete.
no setterinherited
-
aliases
→ List<
String> -
no setterinherited
- aliasesDefinition → CommandAliasesDefinition
-
Returns the aliases definition this command was constructed with, or the
default blank one.
Override this method to provide a dynamic aliases definition.
no setterinherited
- canRunAsLeafCommand → bool
-
finalinherited
- category → String
-
no setterinherited
- description → String
-
Must be overridden by subclass.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasParent → bool
-
no setterinherited
-
no setterinherited
- ignoreUnexpectedPositionalArgs → bool
-
Whether additional positional arguments (that don't match the defined
positional options) are allowed after this command. Defaults to false.
no setterinherited
-
inheritedUsageOptions
→ List<
OptionDefinition> -
The persistent options of the parent commands that are listed in this
command's usage, before its own
options. This affects the usage text only.no setterinherited - invocation → String
-
This command's own invocation, i.e. its name and arguments without
the parent command names.
A subclass that overrides this getter with another text gets that text
in the usage, see
CommandUsageDefinition.invocation.no setterinherited - messageOutput → MessageOutput?
-
no setter
- name → String
-
Must be overridden by subclass.
no setterinherited
-
options
→ List<
O> -
finalinherited
-
parent
↔ AbstractCommand<
OptionDefinition, T> -
Notionally protected; may only be called once.
Throws a StateError if this command already has a parent.
getter/setter pairinherited
- passThroughArgs → bool
-
Whether every argument after this command is left unparsed, to be
passed through to another program. Defaults to false.
no setterinherited
-
persistentOptions
→ List<
O> -
finalinherited
-
runner
→ CommandRunner<
OptionDefinition, T> -
Convenience method to get the root CommandRunner from any command.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
subcommands
→ List<
Command< OptionDefinition, T> > -
Returns the subcommands for this command.
Injects the built-in subcommands (including
help) if there is at least one subcommand and there is not already a subcommand with the same name present.no setterinherited -
suggestionAliases
→ List<
String> -
no setterinherited
- summary → String
-
A short description of this command, shown in the parent's usage.
no setterinherited
- takesArguments → bool
-
no setterinherited
- usage → String
-
Generates a formatted string with usage information for this command.
no setterinherited
- usageDefinition → CommandUsageDefinition
-
Returns the usage definition this command was constructed with, or the
default blank one.
Override this method to provide a dynamic usage definition.
no setterinherited
-
no setterinherited
- usageGenerator → UsageGenerator
-
The usage string generator for this command.
finalinherited
Methods
-
addMiddleware(
Middleware< FutureOr< middleware) → voidT?> , CommandContext<O, T> > -
Adds a middleware to this command.
Middlewares are invoked in the order they are added.
inherited
-
addOption(
O option, {bool? persistent}) → void -
Adds an option to this command.
persistentindicates whether the option should be persistent across this command's subcommands.inherited -
addSubcommand(
Command< OptionDefinition, T> subcommand) → void -
Adds a subcommand to this command.
inherited
-
allOptions(
{bool onlyPersistent = false}) → List< OptionDefinition> -
All the defined options of this command, depending on the passed flag.
inherited
-
completePassThroughArgs(
CommandContext< O, T> context, List<String> words) → FutureOr<CompletionResponse> -
Completes the arguments of this pass-through command, see
passThroughArgs.inherited -
configBroker(
CommandContext< OptionDefinition, T> ? prevContext) → ConfigurationBroker<OptionDefinition> ? -
Provides the configuration broker for resolving the configuration for this
command, if any.
prevContextand its predecessor contexts are the resolved contexts of the parent commands.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
printUsage(
) → void -
inherited
-
resolveCmd(
ArgParseResult< OptionDefinition> parseResult, Map<String, String> ? env, ContextProvider provider, CommandContext<OptionDefinition, T> ? prevContext, {required CommandRunMode runMode}) → CommandContext<O, T> -
Given a parsed command line, environmnent variables, a context provider,
and the resolved command contexts of the parent commands,
resolves the configuration for this command and returns a
CommandContextfor it.inherited -
run(
CommandContext< O, T> context) → FutureOr<T?> -
Runs this command as a leaf command. Implemented by subclasses.
inherited
-
runAsLeaf(
CommandContext< O, T> context) → FutureOr<T?> -
Runs this command as a leaf command.
inherited
-
runCommand(
CommandContext< O, T> context, {CommandHandler<O, T> ? runNextCommand}) → FutureOr<T?> -
Runs this command, including its middlewares (hooks).
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
usageException(
String message) → Never -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited