ArgParser class
A class for taking a list of raw command line arguments and parsing out options and flags from them.
Constructors
- ArgParser({bool allowTrailingOptions = true, int usageLineLength})
-
Creates a new ArgParser. [...]
factory
- ArgParser.allowAnything()
-
Creates a new ArgParser that treats all input as non-option arguments. [...]
factory
Properties
- allowsAnything → bool
-
Whether or not this parser treats unrecognized options as non-option
arguments.
read-only
- allowTrailingOptions → bool
-
Whether or not this parser parses options that appear after non-option
arguments.
final
-
commands
→ Map<
String, ArgParser> -
The commands that have been defined for this parser.
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
-
options
→ Map<
String, Option> -
The options that have been defined for this parser.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- usage → String
-
Generates a string displaying usage information for the defined options. [...]
read-only
- usageLineLength → int
-
An optional maximum line length for usage messages. [...]
final
Methods
-
addCommand(
String name, [ArgParser parser]) → ArgParser - Defines a command. [...]
-
addFlag(
String name, {String abbr, String help, bool defaultsTo = false, bool negatable = true, void callback(bool), bool hide = false}) → void - Defines a boolean flag. [...]
-
addMultiOption(
String name, {String abbr, String help, String valueHelp, Iterable< String> allowed, Map<String, String> allowedHelp, Iterable<String> defaultsTo, void callback(List<String> ), bool splitCommas = true, bool hide = false}) → void - Defines an option that takes multiple values. [...]
-
addOption(
String name, {String abbr, String help, String valueHelp, Iterable< String> allowed, Map<String, String> allowedHelp, String defaultsTo, Function callback, bool allowMultiple = false, bool splitCommas, bool hide = false}) → void - Defines an option that takes a value. [...]
-
addSeparator(
String text) → void - Adds a separator line to the usage. [...]
-
findByAbbreviation(
String abbr) → Option -
Finds the option whose abbreviation is
abbr
, ornull
if no option has that abbreviation. -
getDefault(
String option) → dynamic - Get the default value for an option. Useful after parsing to test if the user specified something other than the default.
-
getUsage(
) → String -
Generates a string displaying usage information for the defined options. [...]
@Deprecated('Replaced with get usage. getUsage() will be removed in args 1.0')
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
parse(
Iterable< String> args) → ArgResults -
Parses
args
, a list of command-line arguments, matches them against the flags and options defined by this parser, and returns the result. -
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited