Releases: andrey-zherikov/argparse
Releases · andrey-zherikov/argparse
v1.4.0
Enhancements
CLI.main
can now accept struct with disabled copy constructor.- Main function passed to
CLI.main
can accept parameter by reference. - Boolean values (
yes
,y
,true
,no
,n
andfalse
) are now parsed case-insensitively. - New checks:
- Argument name can't start with
Config.namedArgChar
(dash-
by default). - For positional arguments within a command:
- There should be no gaps in indexes, e.g.
0,1,3,4
indexes are not allowed because2
is missed. - Indexes should be unique, e.g.
0,1,2,3,2
indexes are not allowed because2
is repeated. - Number of values should be fixed (i.e. minimum number of values should be the same as maximum number of values) unless it's the last positional argument.
- Required positional arguments must go before optional positional arguments.
- Optional positional arguments are not allowed if command has default subcommand.
- There should be no gaps in indexes, e.g.
- Argument name can't start with
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;