Skip to content

Releases: andrey-zherikov/argparse

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;

v0.7.0

13 Mar 05:37
bcfc961
Compare
Choose a tag to compare

Enhancements

  • Added support for subcommands through new SubCommands UDA that can be used to specify subcommands in the parent command (only SumType is supported):

    @SubCommands
    SumType!(cmd1, cmd2) command;
  • New CLI template for mixing main (the original one Main 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 new ShortDescription 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 to Result.