Skip to content

v0.6.0

Compare
Choose a tag to compare
@prajwalch prajwalch released this 13 Sep 15:42
· 5 commits to main since this release
4778cb0

What's New

  • Added new Arg.setValuePlaceholder() to display option's value placeholder in help message. For e.x.: -t, --time=<SECS>.
  • Added new .help_on_empty_args property for a command which, when set, a help message is automatically displayed when arguments are not provided.

Before:

if (!matches.containsArgs()) {
    try app.displayHelp();
    return;
}

if (matches.subcommandMatches("update")) |update_cmd_matches| {
    if (!update_cmd_matches.containsArgs()) {
        try app.displaySubcommandHelp();
        return;
    }
}

After:

var app = App.init(allocator, "myls", "My custom ls");
defer app.deinit();

var myls = app.rootCommand();
myls.setProperty(.help_on_empty_args);

var update_cmd = app.createCommand("update", "Update the app or check for new updates");
update_cmd.setProperty(.help_on_empty_args);

try myls.addSubcommand(update_cmd);

const matches = try myls.parseProcess();

// --snip--

Note that App.displayHelp() and App.displaySubcommandHelp() are still available.

  • Improved error messages.
  • Polished help message.

What's Changed

  • App.parseProcess() and App.parseFrom() now returns ArgMatches directly instead of *const ArgMatches.
  • Add const qualifier in Command.addArgs and Command.addSubcommands. By @monomycelium in #21
  • Fix: Arg.multiValuesOption behavior when single value is provided by @fardragon in #26
  • Fix: compiler crash during zig build test by @fardragon in 8f53fcb
  • Fix: subcommands with no values will never match #23. With this change, ArgMatches.subcommandMatches() now returns empty matches for any subcommand that doesn't take argument.
  • Fix: disable printing error messages during test.

Internal Improvements

  • The parser implementation has been polished to make it easier to contribute by adding inline comments where necessary.
  • Error handling has been enhanced.
  • Improved the help message writer's implementation.
  • Overall documentation is improved.

New Contributors

Full Changelog: v0.5.1...v0.6.0