diff --git a/src/parser.rs b/src/parser.rs index 80fbb75f..f3e9c991 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -474,7 +474,10 @@ fn parse_zero_or_one_value_notation(input: &str) -> nom::IResult<&str, Option<&s // Parse '' 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` diff --git a/tests/snapshots/integration__validate__help_notations.snap b/tests/snapshots/integration__validate__help_notations.snap new file mode 100644 index 00000000..d07e1fd6 --- /dev/null +++ b/tests/snapshots/integration__validate__help_notations.snap @@ -0,0 +1,21 @@ +--- +source: tests/validate.rs +expression: data +--- +************ RUN ************ +prog -h + +OUTPUT +command cat >&2 <<-'EOF' +USAGE: prog [OPTIONS] + +OPTIONS: + -target -- see the targets command + -n volumes for input, '0' to prompt interactively + --merge 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 + + diff --git a/tests/validate.rs b/tests/validate.rs index 9d7af549..99686951 100644 --- a/tests/validate.rs +++ b/tests/validate.rs @@ -42,6 +42,16 @@ fn help_version_exist() { snapshot_multi!(script, [vec!["prog", "-h"]]); } +#[test] +fn help_notations() { + let script = r###" +# @option -target -- see the targets command +# @option -n volumes for input, '0' to prompt interactively +# @option --merge 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"]);