Skip to content

Releases: andrey-zherikov/argparse

v1.4.0

31 Oct 02:34
Compare
Choose a tag to compare

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 and false) 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 because 2 is missed.
      • Indexes should be unique, e.g. 0,1,2,3,2 indexes are not allowed because 2 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.

v1.3.0

10 May 20:51
08e5ea0
Compare
Choose a tag to compare

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

16 Sep 22:09
51dd8de
Compare
Choose a tag to compare

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

29 Aug 13:06
415c1b5
Compare
Choose a tag to compare

Bug fixes

  • Fix for positional argument name where "name" was ignored:
    @PositionalArgument(0, "name")
    string param

v1.1.0

24 Aug 18:31
18c1598
Compare
Choose a tag to compare

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

09 Jun 18:55
Compare
Choose a tag to compare

Bug fixes

  • Positional arguments are printed without dashes in error messages

Breaking changes

  • Deprecated API is removed: parseCLIKnownArgs, parseCLIArgs and Main. Use CLI template instead

v0.11.0

31 May 10:48
e5f8ef8
Compare
Choose a tag to compare

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

25 May 14:26
ce4ca59
Compare
Choose a tag to compare

Enhancements

  • Subcommand description on a help screen will show Description if ShortDescription is not provided.
  • Added shell completion for bash, zsh, tcsh and fish shells. See readme for details.

v0.9.0

24 Apr 03:46
ab8195b
Compare
Choose a tag to compare

Bug fixes

  • Fix parsing of trailing arguments in subcommand

Breaking changes

  • The following functions and templates are deprecated - use CLI(Config config, COMMANDS...) or CLI(COMMANDS...) template:
    • CLI(Config config)
    • Main
    • parseCLIKnownArgs
    • parseCLIArgs

v0.8.0

17 Mar 01:25
8b60bf9
Compare
Choose a tag to compare

Enhancements

  • Added default subcommand:

     @SubCommands
     SumType!(cmd1, Default!cmd2) command;