Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(error): More closely match rustc's error style #4602

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion clap_complete/src/shells/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl FromStr for Shell {
return Ok(*variant);
}
}
Err(format!("Invalid variant: {}", s))
Err(format!("invalid variant: {}", s))
}
}

Expand Down
24 changes: 12 additions & 12 deletions examples/derive_ref/interop_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Value of derived: DerivedArgs {
```console
$ interop_augment_args --unknown
? failed
error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
error: found argument '--unknown' which wasn't expected, or isn't valid in this context

Usage: interop_augment_args[EXE] [OPTIONS]

For more information try '--help'
For more information, try '--help'.

```

Expand Down Expand Up @@ -70,22 +70,22 @@ Derived subcommands: Derived {
```console
$ interop_augment_subcommands derived --unknown
? failed
error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
error: found argument '--unknown' which wasn't expected, or isn't valid in this context

Usage: interop_augment_subcommands[EXE] derived [OPTIONS]

For more information try '--help'
For more information, try '--help'.

```

```console
$ interop_augment_subcommands unknown
? failed
error: The subcommand 'unknown' wasn't recognized
error: the subcommand 'unknown' wasn't recognized

Usage: interop_augment_subcommands[EXE] [COMMAND]

For more information try '--help'
For more information, try '--help'.

```

Expand Down Expand Up @@ -140,13 +140,13 @@ Cli {
```console
$ interop_hand_subcommand add --unknown
? failed
error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
error: found argument '--unknown' which wasn't expected, or isn't valid in this context

note: to pass '--unknown' as a value, use '-- --unknown'

Usage: interop_hand_subcommand[EXE] add [NAME]...

For more information try '--help'
For more information, try '--help'.

```

Expand Down Expand Up @@ -185,11 +185,11 @@ Cli {
```console
$ interop_hand_subcommand unknown
? failed
error: The subcommand 'unknown' wasn't recognized
error: the subcommand 'unknown' wasn't recognized

Usage: interop_hand_subcommand[EXE] [OPTIONS] <COMMAND>

For more information try '--help'
For more information, try '--help'.

```

Expand Down Expand Up @@ -239,10 +239,10 @@ Cli {
```console
$ interop_flatten_hand_args --unknown
? failed
error: Found argument '--unknown' which wasn't expected, or isn't valid in this context
error: found argument '--unknown' which wasn't expected, or isn't valid in this context

Usage: interop_flatten_hand_args[EXE] [OPTIONS]

For more information try '--help'
For more information, try '--help'.

```
4 changes: 2 additions & 2 deletions examples/escaped-positional-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Notice that we can't pass positional arguments before `--`:
```console
$ escaped-positional-derive foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
error: found argument 'foo' which wasn't expected, or isn't valid in this context

Usage: escaped-positional-derive[EXE] [OPTIONS] [-- <SLOP>...]

For more information try '--help'
For more information, try '--help'.

```

Expand Down
4 changes: 2 additions & 2 deletions examples/escaped-positional.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Notice that we can't pass positional arguments before `--`:
```console
$ escaped-positional foo bar
? failed
error: Found argument 'foo' which wasn't expected, or isn't valid in this context
error: found argument 'foo' which wasn't expected, or isn't valid in this context

Usage: escaped-positional[EXE] [OPTIONS] [-- <SLOP>...]

For more information try '--help'
For more information, try '--help'.

```

Expand Down
4 changes: 2 additions & 2 deletions examples/pacman.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ And errors:
```console
$ pacman -S -s foo -i bar
? failed
error: The argument '--search <search>...' cannot be used with '--info'
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'.

```

Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_builder/03_01_flag_bool.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ verbose: true

$ 03_01_flag_bool --verbose --verbose
? failed
error: The argument '--verbose' was provided more than once, but cannot be used multiple times
error: the argument '--verbose' was provided more than once, but cannot be used multiple times

Usage: 03_01_flag_bool[EXE] [OPTIONS]

For more information try '--help'
For more information, try '--help'.

```
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_01_enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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'.

```
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_01_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl std::str::FromStr for Mode {
return Ok(*variant);
}
}
Err(format!("Invalid variant: {}", s))
Err(format!("invalid variant: {}", s))
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_01_possible.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'.

```
8 changes: 4 additions & 4 deletions examples/tutorial_builder/04_02_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ PORT = 22

$ 04_02_parse foobar
? failed
error: Invalid value 'foobar' for '<PORT>': invalid digit found in string
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
error: invalid value '0' for '<PORT>': 0 is not in 1..=65535

For more information try '--help'
For more information, try '--help'.

```
8 changes: 4 additions & 4 deletions examples/tutorial_builder/04_02_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ PORT = 22

$ 04_02_validate foobar
? failed
error: Invalid value 'foobar' for '<PORT>': `foobar` isn't a port number
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
error: invalid value '0' for '<PORT>': port not in range 1-65535

For more information try '--help'
For more information, try '--help'.

```
2 changes: 1 addition & 1 deletion examples/tutorial_builder/04_02_validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn port_in_range(s: &str) -> Result<u16, String> {
Ok(port as u16)
} else {
Err(format!(
"Port not in range {}-{}",
"port not in range {}-{}",
PORT_RANGE.start(),
PORT_RANGE.end()
))
Expand Down
12 changes: 6 additions & 6 deletions examples/tutorial_builder/04_03_relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ Options:

$ 04_03_relations
? failed
error: The following required arguments were not provided:
error: the following required arguments were not provided:
<--set-ver <VER>|--major|--minor|--patch>

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

$ 04_03_relations --major --minor
? failed
error: The argument '--major' cannot be used with '--minor'
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
error: The following required arguments were not provided:
error: the following required arguments were not provided:
<INPUT_FILE|--spec-in <SPEC_IN>>

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
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorial_builder/04_04_custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial_derive/03_01_flag_bool.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ verbose: true

$ 03_01_flag_bool_derive --verbose --verbose
? failed
error: The argument '--verbose' was provided more than once, but cannot be used multiple times
error: the argument '--verbose' was provided more than once, but cannot be used multiple times

Usage: 03_01_flag_bool_derive[EXE] [OPTIONS]

For more information try '--help'
For more information, try '--help'.

```
2 changes: 1 addition & 1 deletion examples/tutorial_derive/04_01_enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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'.

```
8 changes: 4 additions & 4 deletions examples/tutorial_derive/04_02_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ PORT = 22

$ 04_02_parse_derive foobar
? failed
error: Invalid value 'foobar' for '<PORT>': invalid digit found in string
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
error: invalid value '0' for '<PORT>': 0 is not in 1..=65535

For more information try '--help'
For more information, try '--help'.

```
8 changes: 4 additions & 4 deletions examples/tutorial_derive/04_02_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ PORT = 22

$ 04_02_validate_derive foobar
? failed
error: Invalid value 'foobar' for '<PORT>': `foobar` isn't a port number
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
error: invalid value '0' for '<PORT>': port not in range 1-65535

For more information try '--help'
For more information, try '--help'.

```
2 changes: 1 addition & 1 deletion examples/tutorial_derive/04_02_validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn port_in_range(s: &str) -> Result<u16, String> {
Ok(port as u16)
} else {
Err(format!(
"Port not in range {}-{}",
"port not in range {}-{}",
PORT_RANGE.start(),
PORT_RANGE.end()
))
Expand Down
12 changes: 6 additions & 6 deletions examples/tutorial_derive/04_03_relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ Options:

$ 04_03_relations_derive
? failed
error: The following required arguments were not provided:
error: the following required arguments were not provided:
<--set-ver <VER>|--major|--minor|--patch>

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

$ 04_03_relations_derive --major --minor
? failed
error: The argument '--major' cannot be used with '--minor'
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
error: The following required arguments were not provided:
error: the following required arguments were not provided:
<INPUT_FILE|--spec-in <SPEC_IN>>

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
Expand Down