fix(parser): Quote the suggested help

We do it elsewhere but here it is only distinguished coloring.

Inspired by #4218
This commit is contained in:
Ed Page 2022-09-15 14:22:28 -05:00
parent 0479d8eb40
commit 0184cf008a
32 changed files with 87 additions and 87 deletions

View file

@ -25,7 +25,7 @@ error: The following required arguments were not provided:
Usage: custom-bool[EXE] --foo <FOO> <BOOM>
For more information try --help
For more information try '--help'
$ custom-bool --foo true false
[examples/derive_ref/custom-bool.rs:31] opt = Opt {

View file

@ -41,7 +41,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
Usage: interop_augment_args[EXE] [OPTIONS]
For more information try --help
For more information try '--help'
```
@ -78,7 +78,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
Usage: interop_augment_subcommands[EXE] derived [OPTIONS]
For more information try --help
For more information try '--help'
```
@ -89,7 +89,7 @@ error: The subcommand 'unknown' wasn't recognized
Usage: interop_augment_subcommands[EXE] [COMMAND]
For more information try --help
For more information try '--help'
```
@ -150,7 +150,7 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
Usage: interop_hand_subcommand[EXE] add [NAME]...
For more information try --help
For more information try '--help'
```
@ -193,7 +193,7 @@ error: The subcommand 'unknown' wasn't recognized
Usage: interop_hand_subcommand[EXE] [OPTIONS] <COMMAND>
For more information try --help
For more information try '--help'
```
@ -249,6 +249,6 @@ error: Found argument '--unknown' which wasn't expected, or isn't valid in this
Usage: interop_flatten_hand_args[EXE] [OPTIONS]
For more information try --help
For more information try '--help'
```

View file

@ -37,7 +37,7 @@ error: Found argument 'foo' which wasn't expected, or isn't valid in this contex
Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]
For more information try --help
For more information try '--help'
```

View file

@ -37,7 +37,7 @@ error: Found argument 'foo' which wasn't expected, or isn't valid in this contex
Usage: escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]
For more information try --help
For more information try '--help'
```

View file

@ -71,7 +71,7 @@ error: The argument '--search <search>...' cannot be used with '--info'
Usage: pacman[EXE] {sync|--sync|-S} --search <search>... <package>...
For more information try --help
For more information try '--help'
```

View file

@ -22,6 +22,6 @@ $ 04_01_enum medium
error: "medium" isn't a valid value for '<MODE>'
[possible values: fast, slow]
For more information try --help
For more information try '--help'
```

View file

@ -22,6 +22,6 @@ $ 04_01_possible medium
error: "medium" isn't a valid value for '<MODE>'
[possible values: fast, slow]
For more information try --help
For more information try '--help'
```

View file

@ -18,12 +18,12 @@ $ 04_02_parse foobar
? failed
error: Invalid value "foobar" for '<PORT>': invalid digit found in string
For more information try --help
For more information try '--help'
$ 04_02_parse_derive 0
? failed
error: Invalid value "0" for '<PORT>': 0 is not in 1..=65535
For more information try --help
For more information try '--help'
```

View file

@ -18,12 +18,12 @@ $ 04_02_validate foobar
? failed
error: Invalid value "foobar" for '<PORT>': `foobar` isn't a port number
For more information try --help
For more information try '--help'
$ 04_02_validate 0
? failed
error: Invalid value "0" for '<PORT>': Port not in range 1-65535
For more information try --help
For more information try '--help'
```

View file

@ -24,7 +24,7 @@ error: The following required arguments were not provided:
Usage: 04_03_relations[EXE] <--set-ver <VER>|--major|--minor|--patch> [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_03_relations --major
Version: 2.2.3
@ -35,7 +35,7 @@ error: The argument '--major' cannot be used with '--minor'
Usage: 04_03_relations[EXE] <--set-ver <VER>|--major|--minor|--patch> [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_03_relations --major -c config.toml
? failed
@ -44,7 +44,7 @@ error: The following required arguments were not provided:
Usage: 04_03_relations[EXE] -c <CONFIG> <--set-ver <VER>|--major|--minor|--patch> <INPUT_FILE|--spec-in <SPEC_IN>>
For more information try --help
For more information try '--help'
$ 04_03_relations --major -c config.toml --spec-in input.txt
Version: 2.2.3

View file

@ -23,7 +23,7 @@ error: Can only modify one version field
Usage: 04_04_custom[EXE] [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom --major
Version: 2.2.3
@ -34,7 +34,7 @@ error: Can only modify one version field
Usage: 04_04_custom[EXE] [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom --major -c config.toml
? failed
@ -43,7 +43,7 @@ error: INPUT_FILE or --spec-in is required when using --config
Usage: 04_04_custom[EXE] [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom --major -c config.toml --spec-in input.txt
Version: 2.2.3

View file

@ -22,6 +22,6 @@ $ 04_01_enum_derive medium
error: "medium" isn't a valid value for '<MODE>'
[possible values: fast, slow]
For more information try --help
For more information try '--help'
```

View file

@ -18,12 +18,12 @@ $ 04_02_parse_derive foobar
? failed
error: Invalid value "foobar" for '<PORT>': invalid digit found in string
For more information try --help
For more information try '--help'
$ 04_02_parse_derive 0
? failed
error: Invalid value "0" for '<PORT>': 0 is not in 1..=65535
For more information try --help
For more information try '--help'
```

View file

@ -18,12 +18,12 @@ $ 04_02_validate_derive foobar
? failed
error: Invalid value "foobar" for '<PORT>': `foobar` isn't a port number
For more information try --help
For more information try '--help'
$ 04_02_validate_derive 0
? failed
error: Invalid value "0" for '<PORT>': Port not in range 1-65535
For more information try --help
For more information try '--help'
```

View file

@ -24,7 +24,7 @@ error: The following required arguments were not provided:
Usage: 04_03_relations_derive[EXE] <--set-ver <VER>|--major|--minor|--patch> [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_03_relations_derive --major
Version: 2.2.3
@ -35,7 +35,7 @@ error: The argument '--major' cannot be used with '--minor'
Usage: 04_03_relations_derive[EXE] <--set-ver <VER>|--major|--minor|--patch> [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_03_relations_derive --major -c config.toml
? failed
@ -44,7 +44,7 @@ error: The following required arguments were not provided:
Usage: 04_03_relations_derive[EXE] -c <CONFIG> <--set-ver <VER>|--major|--minor|--patch> <INPUT_FILE|--spec-in <SPEC_IN>>
For more information try --help
For more information try '--help'
$ 04_03_relations_derive --major -c config.toml --spec-in input.txt
Version: 2.2.3

View file

@ -23,7 +23,7 @@ error: Can only modify one version field
Usage: clap [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom_derive --major
Version: 2.2.3
@ -34,7 +34,7 @@ error: Can only modify one version field
Usage: clap [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom_derive --major -c config.toml
? failed
@ -43,7 +43,7 @@ error: INPUT_FILE or --spec-in is required when using --config
Usage: clap [OPTIONS] [INPUT_FILE]
For more information try --help
For more information try '--help'
$ 04_04_custom_derive --major -c config.toml --spec-in input.txt
Version: 2.2.3

View file

@ -24,7 +24,7 @@ $ typed-derive -O plaid
? failed
error: Invalid value "plaid" for '-O <OPTIMIZATION>': invalid digit found in string
For more information try --help
For more information try '--help'
```
@ -44,7 +44,7 @@ $ typed-derive --bind localhost
? failed
error: Invalid value "localhost" for '--bind <BIND>': invalid IP address syntax
For more information try --help
For more information try '--help'
```
@ -57,7 +57,7 @@ $ typed-derive --sleep forever
? failed
error: Invalid value "forever" for '--sleep <SLEEP>': expected number at 0
For more information try --help
For more information try '--help'
```
@ -70,12 +70,12 @@ $ typed-derive -D Foo
? failed
error: Invalid value "Foo" for '-D <DEFINES>': invalid KEY=value: no `=` found in `Foo`
For more information try --help
For more information try '--help'
$ typed-derive -D Foo=Bar
? failed
error: Invalid value "Foo=Bar" for '-D <DEFINES>': invalid digit found in string
For more information try --help
For more information try '--help'
```

View file

@ -442,9 +442,9 @@ pub(crate) fn get_help_flag(cmd: &Command) -> Option<&'static str> {
fn try_help(styled: &mut StyledStr, help: Option<&str>) {
if let Some(help) = help {
styled.none("\n\nFor more information try ");
styled.none("\n\nFor more information try '");
styled.good(help.to_owned());
styled.none("\n");
styled.none("'\n");
} else {
styled.none("\n");
}

View file

@ -277,7 +277,7 @@ error: The argument '--flag...' cannot be used with '-F'
Usage: clap-test --flag... --long-option-2 <option2> <positional> <positional2> [positional3]...
For more information try --help
For more information try '--help'
";
utils::assert_output(
@ -295,7 +295,7 @@ error: The argument '-F' cannot be used with '--flag...'
Usage: clap-test -F --long-option-2 <option2> <positional> <positional2> [positional3]...
For more information try --help
For more information try '--help'
";
utils::assert_output(
@ -313,7 +313,7 @@ error: The argument '--flag...' cannot be used with '-F'
Usage: clap-test --flag... --long-option-2 <option2> <positional> <positional2> [positional3]...
For more information try --help
For more information try '--help'
";
utils::assert_output(
@ -331,7 +331,7 @@ error: The argument '-F' cannot be used with '--flag...'
Usage: clap-test -F --long-option-2 <option2> <positional> <positional2> [positional3]...
For more information try --help
For more information try '--help'
";
utils::assert_output(
@ -351,7 +351,7 @@ error: The argument '--one' cannot be used with:
Usage: three_conflicting_arguments --one
For more information try --help
For more information try '--help'
";
let cmd = Command::new("three_conflicting_arguments")

View file

@ -713,7 +713,7 @@ error: The following required arguments were not provided:
Usage: bug <input>
For more information try --help
For more information try '--help'
",
true,
);

View file

@ -16,7 +16,7 @@ error: The following required arguments were not provided:
Usage: prog -b -c
For more information try --help
For more information try '--help'
";
static ONLY_C_ERROR: &str = "\
@ -25,7 +25,7 @@ error: The following required arguments were not provided:
Usage: prog -c -b
For more information try --help
For more information try '--help'
";
fn cmd() -> Command {

View file

@ -120,7 +120,7 @@ fn no_empty_values_without_equals_but_requires_equals() {
Usage: config [OPTIONS]
For more information try --help
For more information try '--help'
";
utils::assert_output(cmd, "config --config", NO_EUQALS_ERROR, true);

View file

@ -27,7 +27,7 @@ fn app_error() {
Usage: test [OPTIONS] --all
For more information try --help
For more information try '--help'
";
let cmd = Command::new("test")
.arg(
@ -139,7 +139,7 @@ error: Found argument 'unused' which wasn't expected, or isn't valid in this con
Usage: test
For more information try --help
For more information try '--help'
";
assert_error(err, expected_kind, MESSAGE, true);
}

View file

@ -8,7 +8,7 @@ error: Found argument '--another-flag' which wasn't expected, or isn't valid in
Usage: mycat [OPTIONS] [filename]
For more information try --help
For more information try '--help'
";
#[test]
@ -184,7 +184,7 @@ error: Found argument '-----' which wasn't expected, or isn't valid in this cont
Usage: test <arg>
For more information try --help
For more information try '--help'
";
let cmd = Command::new("test").arg(Arg::new("arg").action(ArgAction::Set).required(true));

View file

@ -7,7 +7,7 @@ static REQ_GROUP_USAGE: &str = "error: The following required arguments were not
Usage: clap-test <base|--delete>
For more information try --help
For more information try '--help'
";
static REQ_GROUP_CONFLICT_USAGE: &str = "\
@ -15,7 +15,7 @@ error: The argument '--delete' cannot be used with '[base]'
Usage: clap-test <base|--delete>
For more information try --help
For more information try '--help'
";
static REQ_GROUP_CONFLICT_ONLY_OPTIONS: &str = "\
@ -23,7 +23,7 @@ error: The argument '--delete' cannot be used with '--all'
Usage: clap-test <--all|--delete>
For more information try --help
For more information try '--help'
";
#[test]

View file

@ -80,7 +80,7 @@ fn help_multi_subcommand_error() {
Usage: ctest subcmd multi [OPTIONS]
For more information try --help
For more information try '--help'
";
utils::assert_eq(EXPECTED, err.to_string());
}

View file

@ -12,7 +12,7 @@ error: Found argument '--optio' which wasn't expected, or isn't valid in this co
Usage: clap-test --option <opt>... [positional] [positional2] [positional3]...
For more information try --help
For more information try '--help'
";
#[cfg(feature = "suggestions")]
@ -25,7 +25,7 @@ error: Found argument '--files-without-matches' which wasn't expected, or isn't
Usage: ripgrep-616 --files-without-match
For more information try --help
For more information try '--help'
";
#[test]
@ -50,7 +50,7 @@ fn require_equals_fail_message() {
Usage: prog [OPTIONS]
For more information try --help
For more information try '--help'
";
let cmd = Command::new("prog").arg(
Arg::new("cfg")

View file

@ -9,7 +9,7 @@ error: \"slo\" isn't a valid value for '-O <option>'
Did you mean \"slow\"?
For more information try --help
For more information try '--help'
";
#[cfg(not(feature = "suggestions"))]
@ -17,7 +17,7 @@ static PV_ERROR: &str = "\
error: \"slo\" isn't a valid value for '-O <option>'
[possible values: slow, fast, \"ludicrous speed\"]
For more information try --help
For more information try '--help'
";
#[cfg(feature = "suggestions")]
@ -27,7 +27,7 @@ error: \"ludicrous\" isn't a valid value for '-O <option>'
Did you mean \"ludicrous speed\"?
For more information try --help
For more information try '--help'
";
#[cfg(not(feature = "suggestions"))]
@ -35,7 +35,7 @@ static PV_ERROR_ESCAPED: &str = "\
error: \"ludicrous\" isn't a valid value for '-O <option>'
[possible values: slow, fast, \"ludicrous speed\"]
For more information try --help
For more information try '--help'
";
#[test]
@ -301,7 +301,7 @@ static MISSING_PV_ERROR: &str = "\
error: The argument '-O <option>' requires a value but none was supplied
[possible values: slow, fast, \"ludicrous speed\"]
For more information try --help
For more information try '--help'
";
#[test]

View file

@ -9,7 +9,7 @@ error: The following required arguments were not provided:
Usage: clap-test --opt=<FILE>
For more information try --help
For more information try '--help'
";
static REQUIRE_EQUALS_FILTERED: &str = "\
@ -18,7 +18,7 @@ error: The following required arguments were not provided:
Usage: clap-test --opt=<FILE> --foo=<FILE>
For more information try --help
For more information try '--help'
";
static REQUIRE_EQUALS_FILTERED_GROUP: &str = "\
@ -27,7 +27,7 @@ error: The following required arguments were not provided:
Usage: clap-test --opt=<FILE> --foo=<FILE> <--g1=<FILE>|--g2=<FILE>>
For more information try --help
For more information try '--help'
";
static MISSING_REQ: &str = "\
@ -38,7 +38,7 @@ error: The following required arguments were not provided:
Usage: clap-test --long-option-2 <option2> -F <positional> <positional2> [positional3]...
For more information try --help
For more information try '--help'
";
static COND_REQ_IN_USAGE: &str = "\
@ -47,7 +47,7 @@ error: The following required arguments were not provided:
Usage: test --target <target> --input <input> --output <output>
For more information try --help
For more information try '--help'
";
#[test]
@ -143,7 +143,7 @@ error: The following required arguments were not provided:
Usage: clap-test <flag> <opt> [bar]
For more information try --help
For more information try '--help'
";
#[test]
@ -162,7 +162,7 @@ error: The following required arguments were not provided:
Usage: clap-test <flag> [opt] [bar]
For more information try --help
For more information try '--help'
";
#[test]
@ -183,7 +183,7 @@ error: The following required arguments were not provided:
Usage: clap-test <flag> <foo> <opt> [bar]
For more information try --help
For more information try '--help'
";
#[test]
@ -1028,7 +1028,7 @@ error: The following required arguments were not provided:
Usage: example -x <X> -y <Y> -z <Z> <ID>
For more information try --help
For more information try '--help'
";
fn issue_1158_app() -> Command {
@ -1062,7 +1062,7 @@ error: The following required arguments were not provided:
Usage: test --c <c> --a <a> --b <b>
For more information try --help
For more information try '--help'
";
let cmd = Command::new("test")
.arg(
@ -1429,7 +1429,7 @@ error: The argument '-b <b>' cannot be used with '-c <c>'
Usage: clap-test -b <b> <a>
For more information try --help
For more information try '--help'
";
utils::assert_output(cmd, "clap-test aaa -b bbb -c ccc", EXPECTED, true);
}
@ -1451,7 +1451,7 @@ error: The following required arguments were not provided:
Usage: test --require-first <--first|--second>
For more information try --help
For more information try '--help'
";
utils::assert_output(cmd, "test --require-first --second", EXPECTED, true);
}

View file

@ -36,7 +36,7 @@ If you believe you received this message in error, try re-running with 'dym -- s
Usage: dym [COMMAND]
For more information try --help
For more information try '--help'
";
#[cfg(feature = "suggestions")]
@ -49,7 +49,7 @@ If you believe you received this message in error, try re-running with 'dym -- t
Usage: dym [COMMAND]
For more information try --help
For more information try '--help'
";
static SUBCMD_AFTER_DOUBLE_DASH: &str = "\
@ -59,7 +59,7 @@ error: Found argument 'subcmd' which wasn't expected, or isn't valid in this con
Usage: cmd [COMMAND]
For more information try --help
For more information try '--help'
";
#[test]
@ -180,7 +180,7 @@ error: Found argument '--subcmarg' which wasn't expected, or isn't valid in this
Usage: dym [COMMAND]
For more information try --help
For more information try '--help'
";
let cmd = Command::new("dym")
@ -199,7 +199,7 @@ error: Found argument '--subcmarg' which wasn't expected, or isn't valid in this
Usage: dym [COMMAND]
For more information try --help
For more information try '--help'
";
let cmd = Command::new("dym")
@ -433,7 +433,7 @@ fn subcommand_not_recognized() {
Usage: fake [COMMAND]
For more information try --help
For more information try '--help'
",
true,
);
@ -509,7 +509,7 @@ error: The subcommand 'world' wasn't recognized
Usage: <COMMAND>
For more information try help
For more information try 'help'
";
utils::assert_eq(HELLO_EXPECTED, err.to_string());
@ -526,7 +526,7 @@ If you believe you received this message in error, try re-running with ' -- baz'
Usage: <COMMAND>
For more information try help
For more information try 'help'
";
utils::assert_eq(BAZ_EXPECTED, err.to_string());
}

View file

@ -223,7 +223,7 @@ fn derive_generated_error_has_full_context() {
Usage: clap --req-str <REQ_STR>
clap <COMMAND>
For more information try --help
For more information try '--help'
"#;
assert_eq!(result.unwrap_err().to_string(), expected);
}

View file

@ -9,5 +9,5 @@ error: Found argument '--unknown-argument' which wasn't expected, or isn't valid
Usage: stdio-fixture[EXE] [OPTIONS] [COMMAND]
For more information try --help
For more information try '--help'
"""