New
v0.6.0
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_argsproperty 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()andApp.parseFrom()now returnsArgMatchesdirectly instead of*const ArgMatches.- Add
constqualifier inCommand.addArgsandCommand.addSubcommands. By @monomycelium in https://github.com/prajwalch/yazap/pull/21 - Fix:
Arg.multiValuesOptionbehavior when single value is provided by @fardragon in https://github.com/prajwalch/yazap/pull/26 - Fix: compiler crash during
zig build testby @fardragon in https://github.com/prajwalch/yazap/pull/26/commits/8f53fcb3246a5de1c3ce7691bc689c6903206722 - Fix: subcommands with no values will never match https://github.com/prajwalch/yazap/issues/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
- @monomycelium made their first contribution in https://github.com/prajwalch/yazap/pull/21
- @fardragon made their first contribution in https://github.com/prajwalch/yazap/pull/26
Full Changelog: https://github.com/prajwalch/yazap/compare/v0.5.1...v0.6.0