mandatory
options; they now perform validation when the value is retrieved (from the ArgResults
object), instead of when the args are parsed.CONTRIBUTING.md
file; move the publishing automation docs from the readme into the contributing doc.Command.suggestionAliases
for names that cannot be used as aliases, but will trigger suggestions.repository
field.CommandRunner
.suggestionDistanceLimit
parameter on the constructor. You can set it to 0
to disable the feature.mandatory
options which caused a null assertion failure when used within a command.mandatory
argument to require the presence of an option.aliases
named argument to addFlag
, addOption
, and addMultiOption
, as well as a public findByNameOrAlias
method on ArgParser
. This allows you to provide aliases for an argument name, which eases the transition from one argument name to another.Migrate to null safety.
BREAKING Remove APIs that had been marked as deprecated:
allowMulti
and splitCommas
arguments to ArgParser.addOption()
, use ArgParser.addMultiOption()
.ArgParser.getUsage()
, use ArgParser.usage
.Option.abbreviation
, use Option.abbr
.Option.defaultValue
, use Option.defaultsTo
.OptionType.FLAG/SINGLE/MULTIPLE
, use OptionType.flag/single/multiple
.Add a more specific function type to the callback
argument of addOption
.
help
from the list of commands in usage.CommandRunner
in the docs for ArgParser.addCommand
since it is what most authors will want to use instead.usageLineLength
in CommandRunner
usageLineLength
is set.usageLineLength
to control word wrapping usage text.<3.0.0
, and adjust other dependencies.allowedHelp
specified.FutureOr
.Deprecated OptionType.FLAG
, OptionType.SINGLE
, and OptionType.MULTIPLE
in favor of OptionType.flag
, OptionType.single
, and OptionType.multiple
which follow the style guide.
Deprecated Option.abbreviation
and Option.defaultValue
in favor of Option.abbr
and Option.defaultsTo
. This makes all of Option
's fields match the corresponding parameters to ArgParser.addOption()
.
Deprecated the allowMultiple
and splitCommas
arguments to ArgParser.addOption()
in favor of a separate ArgParser.addMultiOption()
method. This allows us to provide more accurate type information, and to avoid adding flags that only make sense for multi-options in places where they might be usable for single-value options.
Command.run()
's return value as FutureOr<T>
.callback
parameter to ArgParser.addOption()
as Function
rather than void Function(value)
. This allows strong-mode users to write callback: (String value) { ... }
rather than having to manually cast value
to a String
(or a List<String>
with allowMultiple: true
).ArgParser.parse()
now takes an Iterable<String>
rather than a List<String>
.
ArgParser.addOption()
's allowed
option now takes an Iterable<String>
rather than a List<String>
.
Breaking change: The allowTrailingOptions
argument to new ArgumentParser()
defaults to true
instead of false
.
Add new ArgParser.allowAnything()
. This allows any input, without parsing any options.
Add explicit support for forwarding the value returned by Command.run()
to CommandRunner.run()
. This worked unintentionally prior to 0.13.6+1.
Add type arguments to CommandRunner
and Command
to indicate the return values of the run()
functions.
CommandRunner
is passed --help
before any commands, it now prints the usage of the chosen command.ArgParser.parse()
now throws an ArgParserException
, which implements FormatException
and has a field that lists the commands that were parsed.
If CommandRunner.run()
encounters a parse error for a subcommand, it now prints the subcommand's usage rather than the global usage.
CommandRunner.argParser
and Command.argParser
to be overridden in strong mode.List<String>
s.By default, only the first line of a command‘s description is included in its parent runner’s usage string. This returns to the default behavior from before 0.13.3+1.
A Command.summary
getter has been added to explicitly control the summary that appears in the parent runner's usage string. This getter defaults to the first line of the description, but can be overridden if the user wants a multi-line summary.
usage
getter in the README.allowTrailingOptions
parameter to new ArgParser()
. This doesn't change the behavior at all; the option already defaulted to false
, and passing in null
still works.getopt
, the de facto standard for option parsing.ArgParser.addSeparator()
. Separators allow users to group their options in the usage text.splitCommas
option.collection
package.Updated dependency constraint on unittest
.
Formatted source code.
Fixed use of deprecated API in example.
help
command for CommandRunner
.Add CommandRunner
and Command
classes which make it easy to build a command-based command-line application.
Add an ArgResults.arguments
field, which contains the original argument list.
ArgParser.getUsage()
with ArgParser.usage
, a getter. ArgParser.getUsage()
is now deprecated, to be removed in args version 1.0.0.collection
package.Removed public constructors for ArgResults
and Option
.
ArgResults.wasParsed()
can be used to determine if an option was actually parsed or the default value is being returned.
Replaced isFlag
and allowMultiple
fields in the Option
class with a three-value OptionType
enum.
Options may define valueHelp
which will then be shown in the usage.
ArgParser.parse()
into ArgParser
itself. This lets subcommands have different behavior for how they handle trailing options.