- Add a
mandatory
argument to require the presence of an option. - Add
aliases
named argument toaddFlag
,addOption
, andaddMultiOption
, as well as a publicfindByNameOrAlias
method onArgParser
. This allows you to provide aliases for an argument name, which eases the transition from one argument name to another.
- Stable null safety release.
-
Migrate to null safety.
-
BREAKING Remove APIs that had been marked as deprecated:
- Instead of the
allowMulti
andsplitCommas
arguments toArgParser.addOption()
, useArgParser.addMultiOption()
. - Instead of
ArgParser.getUsage()
, useArgParser.usage
. - Instead of
Option.abbreviation
, useOption.abbr
. - Instead of
Option.defaultValue
, useOption.defaultsTo
. - Instead of
OptionType.FLAG/SINGLE/MULTIPLE
, useOptionType.flag/single/multiple
.
- Instead of the
-
Add a more specific function type to the
callback
argument ofaddOption
.
- Remove
help
from the list of commands in usage. - Remove the blank lines in usage which separated the help for options that happened to span multiple lines.
- Fix a bug with option names containing underscores.
- Point towards
CommandRunner
in the docs forArgParser.addCommand
since it is what most authors will want to use instead.
- Improve arg parsing performance: use queues instead of lists internally to get linear instead of quadratic performance, which is important for large numbers of args (>1000). And, use simple string manipulation instead of regular expressions for a 1.5x improvement everywhere.
- No longer automatically add a 'help' option to commands that don't validate their arguments (fix #123).
- Added support for
usageLineLength
inCommandRunner
- Added more comprehensive word wrapping when
usageLineLength
is set.
- Add
usageLineLength
to control word wrapping usage text.
- Set max SDK version to
<3.0.0
, and adjust other dependencies.
- Display the default values for options with
allowedHelp
specified.
- Narrow the SDK constraint to only allow SDK versions that support
FutureOr
.
- Fix the way default values for multi-valued options are printed in argument usage.
-
Deprecated
OptionType.FLAG
,OptionType.SINGLE
, andOptionType.MULTIPLE
in favor ofOptionType.flag
,OptionType.single
, andOptionType.multiple
which follow the style guide. -
Deprecated
Option.abbreviation
andOption.defaultValue
in favor ofOption.abbr
andOption.defaultsTo
. This makes all ofOption
's fields match the corresponding parameters toArgParser.addOption()
. -
Deprecated the
allowMultiple
andsplitCommas
arguments toArgParser.addOption()
in favor of a separateArgParser.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.
- Type
Command.run()
's return value asFutureOr<T>
.
- Type the
callback
parameter toArgParser.addOption()
asFunction
rather thanvoid Function(value)
. This allows strong-mode users to writecallback: (String value) { ... }
rather than having to manually castvalue
to aString
(or aList<String>
withallowMultiple: true
).
-
ArgParser.parse()
now takes anIterable<String>
rather than aList<String>
. -
ArgParser.addOption()
'sallowed
option now takes anIterable<String>
rather than aList<String>
.
- Fix analyzer warning
- Fix a fuzzy arrow type warning.
-
Breaking change: The
allowTrailingOptions
argument tonew ArgumentParser()
defaults totrue
instead offalse
. -
Add
new ArgParser.allowAnything()
. This allows any input, without parsing any options.
-
Add explicit support for forwarding the value returned by
Command.run()
toCommandRunner.run()
. This worked unintentionally prior to 0.13.6+1. -
Add type arguments to
CommandRunner
andCommand
to indicate the return values of therun()
functions.
- When a
CommandRunner
is passed--help
before any commands, it now prints the usage of the chosen command.
-
ArgParser.parse()
now throws anArgParserException
, which implementsFormatException
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.
- Allow
CommandRunner.argParser
andCommand.argParser
to be overridden in strong mode.
- Fix a minor documentation error.
- Ensure that multiple-value arguments produce reified
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.
- README fixes.
- Make strong mode clean.
- Use the proper
usage
getter in the README.
- Add an explicit default value for the
allowTrailingOptions
parameter tonew ArgParser()
. This doesn't change the behavior at all; the option already defaulted tofalse
, and passing innull
still works.
- Documentation fixes.
- Print all lines of multi-line command descriptions.
- Allow option values that look like options. This more closely matches the
behavior of
getopt
, the de facto standard for option parsing.
- Add
ArgParser.addSeparator()
. Separators allow users to group their options in the usage text.
- Breaking change: An option that allows multiple values will now
automatically split apart comma-separated values. This can be controlled with
the
splitCommas
option.
- Remove the dependency on the
collection
package.
- Add syntax highlighting to the README.
- Add an example of using command-line arguments to the README.
- Fixed implementation of ArgResults.options to really use Iterable instead of Iterable cast to Iterable.
-
Updated dependency constraint on
unittest
. -
Formatted source code.
-
Fixed use of deprecated API in example.
- Fix the built-in
help
command forCommandRunner
.
-
Add
CommandRunner
andCommand
classes which make it easy to build a command-based command-line application. -
Add an
ArgResults.arguments
field, which contains the original argument list.
- Replace
ArgParser.getUsage()
withArgParser.usage
, a getter.ArgParser.getUsage()
is now deprecated, to be removed in args version 1.0.0.
- Widen the version constraint on the
collection
package.
- Remove the documentation link from the pubspec so this is linked to pub.dev by default.
-
Removed public constructors for
ArgResults
andOption
. -
ArgResults.wasParsed()
can be used to determine if an option was actually parsed or the default value is being returned. -
Replaced
isFlag
andallowMultiple
fields in theOption
class with a three-valueOptionType
enum. -
Options may define
valueHelp
which will then be shown in the usage.
- Move handling trailing options from
ArgParser.parse()
intoArgParser
itself. This lets subcommands have different behavior for how they handle trailing options.
- Usage ignores hidden options when determining column widths.