ArgParser class

A base argument parser, shared by AppArgParser and CommandParser.

Methods ending with S are shorthand for adding positionals and options that parse strings, by setting the parser to idValueParser. Similarly, methods ending in N use null as the default value. Methods ending in SN combine both: they parse strings with null as a default.

Implementers

Properties

args ArgumentSet
A list of all registered arguments. This interface is not guaranteed to be stable!
no setter
commandParsers Map<String, CommandParser>
no setter
hashCode int
The hash code for this object.
no setterinherited
info UsageInfo
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
usageContext UsageContext
final
usageGroups Set<UsageGroup>
A list of all registered usage groups. This interface is not guaranteed to be stable!
no setter
usagePrinter UsagePrinter
final

Methods

addCommands<T>({required ValueParser<T> parser, ValuePrinter<T>? printer}) CommandSet<T>
Sets up this parser to parse subcommands.
addCommandsS() CommandSet<String>
Shorthand for addCommands for strings.
addFlag(String name, {String? description, UsageGroup? usageGroup, String? short, String? inverse, bool defaultValue = false, void onParse(bool value)?}) Arg<bool>
Adds a new boolean flag.
addMultiFlag<U>(String name, {String? description, UsageGroup? usageGroup, String? short, String? inverse, required U defaultValue, required Accumulator<bool, U> accumulator, void onParse(bool value)?}) Arg<U>
Adds a new boolean flag that can be passed multiple times.
addMultiOption<T, U>(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short, required U defaultValue, required ValueParser<T> parser, ValuePrinter<T>? printer, required Accumulator<T, U> accumulator}) Arg<U>
Adds a new option that can be passed multiple times.
addMultiOptionN<T, U>(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short, required ValueParser<T> parser, ValuePrinter<T>? printer, required Accumulator<T, U> accumulator}) Arg<U?>
Shorthand for addMultiOption with a default value of null.
addMultiOptionS<U>(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short, required U defaultValue, required Accumulator<String, U> accumulator}) Arg<U>
Shorthand for addMultiOption for strings.
addMultiOptionSN<U>(String name, {String? description, String? valueDescription, String? short, required Accumulator<String, U> accumulator}) Arg<U?>
Shorthand for addMultiOption for strings with a default value of null.
addMultiPositional<T, U>(String name, {String? description, UsageGroup? usageGroup, Requires<U>? requires, required ValueParser<T> parser, ValuePrinter<T>? printer, required Accumulator<T, U> accumulator, bool? noOptionsFollowing}) Arg<U>
Adds a new positional argument that can take multiple values.
addMultiPositionalS<U>(String name, {String? description, UsageGroup? usageGroup, Requires<U>? requires, required Accumulator<String, U> accumulator, bool? noOptionsFollowing}) Arg<U>
Shorthand for addMultiPositional for strings.
addOption<T>(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short, required T defaultValue, required ValueParser<T> parser, ValuePrinter<T>? printer}) Arg<T>
Adds a new option.
addOptionN<T>(String name, {String? description, UsageGroup? usageGroup, String? valueDescription, String? short, required ValueParser<T> parser, ValuePrinter<T>? printer}) Arg<T?>
Shorthand for addOption with a default value of null.
addOptionS(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short, required String defaultValue}) Arg<String>
Shorthand for addOption for strings.
addOptionSN(String name, {String? description, String? valueDescription, UsageGroup? usageGroup, String? short}) Arg<String?>
Shorthand for addOption for strings with a default value of null.
addPositional<T>(String name, {String? description, UsageGroup? usageGroup, Requires<T>? requires, required ValueParser<T> parser, ValuePrinter<T>? printer, bool? noOptionsFollowing}) Arg<T>
Adds a new positional argument.
addPositionalN<T>(String name, {String? description, UsageGroup? usageGroup, required ValueParser<T> parser, ValuePrinter<T?>? printer, bool? noOptionsFollowing}) Arg<T?>
Shorthand for addPositional with a default value of null.
addPositionalS(String name, {String? description, UsageGroup? usageGroup, Requires<String>? requires, bool? noOptionsFollowing}) Arg<String>
Shorthand for addPositional for strings.
addPositionalSN(String name, {String? description, UsageGroup? usageGroup, bool? noOptionsFollowing}) Arg<String?>
Shorthand for addPositional for strings with a default value of null.
createUsageGroup(String name) UsageGroup
Creates a new usage group with the given name.
findSelectedParser() ArgParser
Returns the farthest parser the user has selected (i.e. given mycommand subcommand1 subcommand2, returns the parser for subcommand2). This interface is not guaranteed to be stable!
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
printUsage({StringSink? sink, bool showShortUsage = false}) → void
Prints the usage information using this parser's usagePrinter to the given sink. If showShortUsage is true, then the printed usage will only contain the "Usage:" line showing a brief summary of how to use this parser.
toString() String
A string representation of this object.
inherited

Operators

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