CommandRunner<T> class

A class for invoking Commands based on raw command-line arguments.

The type argument T represents the type returned by and; it can be ommitted if you're not using the return values.


CommandRunner(String executableName, String description, {int? usageLineLength, int suggestionDistanceLimit = 2})


argParser ArgParser
The top-level argument parser.
no setter
commands Map<String, Command<T>>
An unmodifiable view of all top-level commands defined for this runner.
no setter
description String
A short description of this executable.
executableName String
The name of the executable being run.
hashCode int
The hash code for this object.
no setterinherited
invocation String
A single-line template for how to invoke this executable.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
suggestionDistanceLimit int
The maximum edit distance allowed when suggesting possible intended commands.
usage String
Generates a string displaying usage information for the executable.
no setter
usageFooter String?
An optional footer for usage.
no setter


addCommand(Command<T> command) → void
Adds Command as a top-level command to this runner.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
parse(Iterable<String> args) ArgResults
Parses args and returns the result, converting an ArgParserException to a UsageException.
printUsage() → void
Prints the usage information for this runner.
run(Iterable<String> args) Future<T?>
Parses args and invokes on the chosen command.
runCommand(ArgResults topLevelResults) Future<T?>
Runs the command specified by topLevelResults.
toString() String
A string representation of this object.
usageException(String message) → Never
Throws a UsageException with message.


operator ==(Object other) bool
The equality operator.