Releases: andrey-zherikov/argparse
v1.3.0
Enhancements
- You can now customize what values are accepted in command line for
enum
types:struct T { enum Fruit { apple, @ArgumentValue("no-apple","noapple") noapple }; Fruit a; } assert(CLI!T.parseArgs!((T t) { assert(t == T(T.Fruit.apple)); })(["-a","apple"]) == 0); assert(CLI!T.parseArgs!((T t) { assert(t == T(T.Fruit.noapple)); })(["-a=no-apple"]) == 0); assert(CLI!T.parseArgs!((T t) { assert(t == T(T.Fruit.noapple)); })(["-a","noapple"]) == 0);
Other changes
- Code has been widely refactored to have more clear responsibility separation between components
- New testing mode in CI:
-preview=in
v1.2.0
Enhancements
- Add support of custom types:
struct Value { string a; } struct T { @(NamedArgument.Parse!((string s) { return Value(s); })) Value s; }
Bug fixes
-
Fix for the case when main program is attributed with
Command
without name:@(Command.Description("Description of main program")) struct Program { ... }
-
Ignore arguments with long invocation text during indent calculation for help text:
Optional arguments: -x X 1 x --yyyyyyyyyyyy YYYYYYYYYYYY 12 ys -h, --help Show this help message and exit
v1.1.1
Bug fixes
- Fix for positional argument name where
"name"
was ignored:@PositionalArgument(0, "name") string param
v1.1.0
Enhancements
-
ANSI colors and styles - see readme for details:
-
Help text API (
Usage
,Description
,ShortDescription
,Epilog
) now support delegates that return string. This is useful when string is not available at compile time:Description(() => "Print sum of the numbers")
Bug fixes
- Fix build failure when built with
-dip1000
.
v1.0.0
Bug fixes
- Positional arguments are printed without dashes in error messages
Breaking changes
- Deprecated API is removed:
parseCLIKnownArgs
,parseCLIArgs
andMain
. UseCLI
template instead
v0.11.0
Bug fixes
- Subcommand data member was not correctly initialized if command line has no argument for it.
--help
/-h
did not show correct help screen in case of default subcommand.
Enhancements
- MutuallyExclusive and RequiredTogether can be marked as required:
struct T { @RequiredTogether() { string a; string b; } } // Both or no argument is allowed assert(CLI!T.parseArgs!((T t) {})(["-a","a","-b","b"]) == 0); assert(CLI!T.parseArgs!((T t) {})([]) == 0); // Only one argument is not allowed assert(CLI!T.parseArgs!((T t) { assert(false); })(["-a","a"]) != 0); assert(CLI!T.parseArgs!((T t) { assert(false); })(["-b","b"]) != 0);
struct T { @(RequiredTogether().Required()) { string a; string b; } } // Both arguments are allowed assert(CLI!T.parseArgs!((T t) {})(["-a","a","-b","b"]) == 0); // Single argument or no argument is not allowed assert(CLI!T.parseArgs!((T t) { assert(false); })(["-a","a"]) != 0); assert(CLI!T.parseArgs!((T t) { assert(false); })(["-b","b"]) != 0); assert(CLI!T.parseArgs!((T t) { assert(false); })([]) != 0);
v0.10.0
Enhancements
- Subcommand description on a help screen will show
Description
ifShortDescription
is not provided. - Added shell completion for bash, zsh, tcsh and fish shells. See readme for details.
v0.9.0
Bug fixes
- Fix parsing of trailing arguments in subcommand
Breaking changes
- The following functions and templates are deprecated - use
CLI(Config config, COMMANDS...)
orCLI(COMMANDS...)
template:CLI(Config config)
Main
parseCLIKnownArgs
parseCLIArgs
v0.8.0
Enhancements
-
Added default subcommand:
@SubCommands SumType!(cmd1, Default!cmd2) command;
v0.7.0
Enhancements
-
Added support for subcommands through new
SubCommands
UDA that can be used to specify subcommands in the parent command (onlySumType
is supported):@SubCommands SumType!(cmd1, cmd2) command;
-
New
CLI
template for mixingmain
(the original oneMain
will be removed soon):mixin CLI!Program.main!newMain; mixin CLI!(CMD1, CMD2, CMD3).main!newMain mixin CLI!(config, Program).main!newMain; mixin CLI!(config, CMD1, CMD2, CMD3).main!newMain
-
Command
UDA got newShortDescription
function to set a command description that's shown in "Available commands" section on help text of the parent command. -
Added support of multi-line argument description (i.e. those that has
'\n'
).
Breaking changes
ParseCLIResult
is renamed toResult
.