Skip to content

Commit

Permalink
fix(#4): Return CommandArgumentNotProvided only when argRequired
Browse files Browse the repository at this point in the history
…is set
  • Loading branch information
PrajwalCH committed Sep 4, 2022
1 parent 35664a6 commit b8adda8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parser/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ fn parseSubCommand(
or valid_subcmd.subcommands.items.len >= 1) {
// zig fmt: on
const subcmd_argv = self.tokenizer.restArg() orelse {
if (!(valid_subcmd.setting.arg_required)) {
return MatchedSubCommand.initWithoutArg(valid_subcmd.name);
}
self.err_ctx.setCmd(valid_subcmd);
self.err_ctx.setErr(Error.CommandArgumentNotProvided);
return self.err_ctx.err;
Expand Down

0 comments on commit b8adda8

Please sign in to comment.