Skip to content

Commit

Permalink
fix: notations are seperated by only one space (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Aug 29, 2023
1 parent 7c15c29 commit 2cd7775
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ fn parse_zero_or_one_value_notation(input: &str) -> nom::IResult<&str, Option<&s

// Parse '<FOO>'
fn parse_value_notation(input: &str) -> nom::IResult<&str, &str> {
preceded(space0, delimited(char('<'), parse_notation_text, char('>')))(input)
preceded(
one_of(" "),
delimited(char('<'), parse_notation_text, char('>')),
)(input)
}

// Parse `a|b|c`
Expand Down
21 changes: 21 additions & 0 deletions tests/snapshots/integration__validate__help_notations.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: tests/validate.rs
expression: data
---
************ RUN ************
prog -h

OUTPUT
command cat >&2 <<-'EOF'
USAGE: prog [OPTIONS]

OPTIONS:
-target <NAME> <arch><sub>-<os>-<abi> see the targets command
-n <NUM> <num> volumes for input, '0' to prompt interactively
--merge <PATH1> <PATH2> <BASE> <RESULT> Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions and the output file to save merge results.
-h, -help Print help

EOF
exit 0


10 changes: 10 additions & 0 deletions tests/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ fn help_version_exist() {
snapshot_multi!(script, [vec!["prog", "-h"]]);
}

#[test]
fn help_notations() {
let script = r###"
# @option -target <name> <arch><sub>-<os>-<abi> see the targets command
# @option -n <num> <num> volumes for input, '0' to prompt interactively
# @option --merge <path1> <path2> <base> <result> Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions and the output file to save merge results.
"###;
snapshot_multi!(script, [vec!["prog", "-h"]]);
}

#[test]
fn arg_help_subcmd() {
snapshot!(SCRIPT_ARGS, &["prog", "help", "cmdd"]);
Expand Down

0 comments on commit 2cd7775

Please sign in to comment.