From c2efb60a5fe15cdb1b6cb7ff6922985df89e70ec Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 3 Jan 2023 10:22:40 -0600 Subject: [PATCH 1/2] fix(error): Lowercase the start of error messages This matches the rustc error style --- clap_complete/src/shells/shell.rs | 2 +- examples/derive_ref/interop_tests.md | 12 ++++----- examples/escaped-positional-derive.md | 2 +- examples/escaped-positional.md | 2 +- examples/pacman.md | 2 +- examples/tutorial_builder/03_01_flag_bool.md | 2 +- examples/tutorial_builder/04_01_enum.rs | 2 +- examples/tutorial_builder/04_02_parse.md | 4 +-- examples/tutorial_builder/04_02_validate.md | 4 +-- examples/tutorial_builder/04_02_validate.rs | 2 +- examples/tutorial_builder/04_03_relations.md | 6 ++--- examples/tutorial_derive/03_01_flag_bool.md | 2 +- examples/tutorial_derive/04_02_parse.md | 4 +-- examples/tutorial_derive/04_02_validate.md | 4 +-- examples/tutorial_derive/04_02_validate.rs | 2 +- examples/tutorial_derive/04_03_relations.md | 6 ++--- examples/typed-derive.md | 14 +++++------ src/derive.rs | 2 +- src/error/format.rs | 26 ++++++++++---------- src/error/kind.rs | 26 ++++++++++---------- src/util/color.rs | 2 +- tests/builder/conflicts.rs | 18 +++++++------- tests/builder/default_missing_vals.rs | 2 +- tests/builder/default_vals.rs | 8 +++--- tests/builder/double_require.rs | 4 +-- tests/builder/empty_values.rs | 2 +- tests/builder/error.rs | 14 +++++------ tests/builder/flags.rs | 6 ++--- tests/builder/groups.rs | 10 ++++---- tests/builder/help.rs | 2 +- tests/builder/opts.rs | 6 ++--- tests/builder/possible_values.rs | 2 +- tests/builder/require.rs | 26 ++++++++++---------- tests/builder/subcommands.rs | 16 ++++++------ tests/derive/groups.rs | 2 +- tests/ui/error_stderr.toml | 2 +- 36 files changed, 124 insertions(+), 124 deletions(-) diff --git a/clap_complete/src/shells/shell.rs b/clap_complete/src/shells/shell.rs index f6e70f575d7..4ae4a79ce9f 100644 --- a/clap_complete/src/shells/shell.rs +++ b/clap_complete/src/shells/shell.rs @@ -42,7 +42,7 @@ impl FromStr for Shell { return Ok(*variant); } } - Err(format!("Invalid variant: {}", s)) + Err(format!("invalid variant: {}", s)) } } diff --git a/examples/derive_ref/interop_tests.md b/examples/derive_ref/interop_tests.md index bd36fc20ff1..961f216717e 100644 --- a/examples/derive_ref/interop_tests.md +++ b/examples/derive_ref/interop_tests.md @@ -35,7 +35,7 @@ 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] @@ -70,7 +70,7 @@ 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] @@ -81,7 +81,7 @@ 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] @@ -140,7 +140,7 @@ 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' @@ -185,7 +185,7 @@ 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] @@ -239,7 +239,7 @@ 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] diff --git a/examples/escaped-positional-derive.md b/examples/escaped-positional-derive.md index befcd30766d..3b7dc6a1510 100644 --- a/examples/escaped-positional-derive.md +++ b/examples/escaped-positional-derive.md @@ -33,7 +33,7 @@ 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] [-- ...] diff --git a/examples/escaped-positional.md b/examples/escaped-positional.md index 6fc38981d00..fff558a45de 100644 --- a/examples/escaped-positional.md +++ b/examples/escaped-positional.md @@ -33,7 +33,7 @@ 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] [-- ...] diff --git a/examples/pacman.md b/examples/pacman.md index 6bc1de8200d..d700e694f9e 100644 --- a/examples/pacman.md +++ b/examples/pacman.md @@ -67,7 +67,7 @@ And errors: ```console $ pacman -S -s foo -i bar ? failed -error: The argument '--search ...' cannot be used with '--info' +error: the argument '--search ...' cannot be used with '--info' Usage: pacman[EXE] {sync|--sync|-S} --search ... ... diff --git a/examples/tutorial_builder/03_01_flag_bool.md b/examples/tutorial_builder/03_01_flag_bool.md index 161c9e516c0..c666f6cfe92 100644 --- a/examples/tutorial_builder/03_01_flag_bool.md +++ b/examples/tutorial_builder/03_01_flag_bool.md @@ -17,7 +17,7 @@ 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] diff --git a/examples/tutorial_builder/04_01_enum.rs b/examples/tutorial_builder/04_01_enum.rs index a8b0e6858d4..1afa018a1a4 100644 --- a/examples/tutorial_builder/04_01_enum.rs +++ b/examples/tutorial_builder/04_01_enum.rs @@ -38,7 +38,7 @@ impl std::str::FromStr for Mode { return Ok(*variant); } } - Err(format!("Invalid variant: {}", s)) + Err(format!("invalid variant: {}", s)) } } diff --git a/examples/tutorial_builder/04_02_parse.md b/examples/tutorial_builder/04_02_parse.md index c6f91fd14cc..a9a8d8c8775 100644 --- a/examples/tutorial_builder/04_02_parse.md +++ b/examples/tutorial_builder/04_02_parse.md @@ -16,13 +16,13 @@ PORT = 22 $ 04_02_parse foobar ? failed -error: Invalid value 'foobar' for '': invalid digit found in string +error: invalid value 'foobar' for '': invalid digit found in string For more information try '--help' $ 04_02_parse_derive 0 ? failed -error: Invalid value '0' for '': 0 is not in 1..=65535 +error: invalid value '0' for '': 0 is not in 1..=65535 For more information try '--help' diff --git a/examples/tutorial_builder/04_02_validate.md b/examples/tutorial_builder/04_02_validate.md index 0c879fe062b..9096933be28 100644 --- a/examples/tutorial_builder/04_02_validate.md +++ b/examples/tutorial_builder/04_02_validate.md @@ -16,13 +16,13 @@ PORT = 22 $ 04_02_validate foobar ? failed -error: Invalid value 'foobar' for '': `foobar` isn't a port number +error: invalid value 'foobar' for '': `foobar` isn't a port number For more information try '--help' $ 04_02_validate 0 ? failed -error: Invalid value '0' for '': Port not in range 1-65535 +error: invalid value '0' for '': port not in range 1-65535 For more information try '--help' diff --git a/examples/tutorial_builder/04_02_validate.rs b/examples/tutorial_builder/04_02_validate.rs index ea2f32e679a..4690e8e1239 100644 --- a/examples/tutorial_builder/04_02_validate.rs +++ b/examples/tutorial_builder/04_02_validate.rs @@ -28,7 +28,7 @@ fn port_in_range(s: &str) -> Result { Ok(port as u16) } else { Err(format!( - "Port not in range {}-{}", + "port not in range {}-{}", PORT_RANGE.start(), PORT_RANGE.end() )) diff --git a/examples/tutorial_builder/04_03_relations.md b/examples/tutorial_builder/04_03_relations.md index 8fec2d5db26..304d392a232 100644 --- a/examples/tutorial_builder/04_03_relations.md +++ b/examples/tutorial_builder/04_03_relations.md @@ -19,7 +19,7 @@ Options: $ 04_03_relations ? failed -error: The following required arguments were not provided: +error: the following required arguments were not provided: <--set-ver |--major|--minor|--patch> Usage: 04_03_relations[EXE] <--set-ver |--major|--minor|--patch> [INPUT_FILE] @@ -31,7 +31,7 @@ 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 |--major|--minor|--patch> [INPUT_FILE] @@ -39,7 +39,7 @@ 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: > Usage: 04_03_relations[EXE] -c <--set-ver |--major|--minor|--patch> > diff --git a/examples/tutorial_derive/03_01_flag_bool.md b/examples/tutorial_derive/03_01_flag_bool.md index c7ce587ee96..cd8d7bde419 100644 --- a/examples/tutorial_derive/03_01_flag_bool.md +++ b/examples/tutorial_derive/03_01_flag_bool.md @@ -17,7 +17,7 @@ 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] diff --git a/examples/tutorial_derive/04_02_parse.md b/examples/tutorial_derive/04_02_parse.md index 6d623ec0abb..7915dedf69d 100644 --- a/examples/tutorial_derive/04_02_parse.md +++ b/examples/tutorial_derive/04_02_parse.md @@ -16,13 +16,13 @@ PORT = 22 $ 04_02_parse_derive foobar ? failed -error: Invalid value 'foobar' for '': invalid digit found in string +error: invalid value 'foobar' for '': invalid digit found in string For more information try '--help' $ 04_02_parse_derive 0 ? failed -error: Invalid value '0' for '': 0 is not in 1..=65535 +error: invalid value '0' for '': 0 is not in 1..=65535 For more information try '--help' diff --git a/examples/tutorial_derive/04_02_validate.md b/examples/tutorial_derive/04_02_validate.md index 067a1202e9f..21480d3e734 100644 --- a/examples/tutorial_derive/04_02_validate.md +++ b/examples/tutorial_derive/04_02_validate.md @@ -16,13 +16,13 @@ PORT = 22 $ 04_02_validate_derive foobar ? failed -error: Invalid value 'foobar' for '': `foobar` isn't a port number +error: invalid value 'foobar' for '': `foobar` isn't a port number For more information try '--help' $ 04_02_validate_derive 0 ? failed -error: Invalid value '0' for '': Port not in range 1-65535 +error: invalid value '0' for '': port not in range 1-65535 For more information try '--help' diff --git a/examples/tutorial_derive/04_02_validate.rs b/examples/tutorial_derive/04_02_validate.rs index 2b81ef2417f..513084dffb1 100644 --- a/examples/tutorial_derive/04_02_validate.rs +++ b/examples/tutorial_derive/04_02_validate.rs @@ -26,7 +26,7 @@ fn port_in_range(s: &str) -> Result { Ok(port as u16) } else { Err(format!( - "Port not in range {}-{}", + "port not in range {}-{}", PORT_RANGE.start(), PORT_RANGE.end() )) diff --git a/examples/tutorial_derive/04_03_relations.md b/examples/tutorial_derive/04_03_relations.md index db4c0ce1c49..09fbdbff6fb 100644 --- a/examples/tutorial_derive/04_03_relations.md +++ b/examples/tutorial_derive/04_03_relations.md @@ -19,7 +19,7 @@ Options: $ 04_03_relations_derive ? failed -error: The following required arguments were not provided: +error: the following required arguments were not provided: <--set-ver |--major|--minor|--patch> Usage: 04_03_relations_derive[EXE] <--set-ver |--major|--minor|--patch> [INPUT_FILE] @@ -31,7 +31,7 @@ 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 |--major|--minor|--patch> [INPUT_FILE] @@ -39,7 +39,7 @@ 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: > Usage: 04_03_relations_derive[EXE] -c <--set-ver |--major|--minor|--patch> > diff --git a/examples/typed-derive.md b/examples/typed-derive.md index 9544b2f039e..047beb9c743 100644 --- a/examples/typed-derive.md +++ b/examples/typed-derive.md @@ -24,7 +24,7 @@ Args { optimization: Some(1), include: None, bind: None, sleep: None, defines: [ $ typed-derive -O plaid ? failed -error: Invalid value 'plaid' for '-O ': invalid digit found in string +error: invalid value 'plaid' for '-O ': invalid digit found in string For more information try '--help' @@ -44,7 +44,7 @@ Args { optimization: None, include: None, bind: Some(192.0.0.1), sleep: None, de $ typed-derive --bind localhost ? failed -error: Invalid value 'localhost' for '--bind ': invalid IP address syntax +error: invalid value 'localhost' for '--bind ': invalid IP address syntax For more information try '--help' @@ -57,7 +57,7 @@ Args { optimization: None, include: None, bind: None, sleep: Some(Duration(10s)) $ typed-derive --sleep forever ? failed -error: Invalid value 'forever' for '--sleep ': expected number at 0 +error: invalid value 'forever' for '--sleep ': expected number at 0 For more information try '--help' @@ -70,13 +70,13 @@ Args { optimization: None, include: None, bind: None, sleep: None, defines: [("F $ typed-derive -D Foo ? failed -error: Invalid value 'Foo' for '-D ': invalid KEY=value: no `=` found in `Foo` +error: invalid value 'Foo' for '-D ': invalid KEY=value: no `=` found in `Foo` For more information try '--help' $ typed-derive -D Foo=Bar ? failed -error: Invalid value 'Foo=Bar' for '-D ': invalid digit found in string +error: invalid value 'Foo=Bar' for '-D ': invalid digit found in string For more information try '--help' @@ -92,7 +92,7 @@ Args { optimization: None, include: None, bind: None, sleep: None, defines: [], $ typed-derive --port ? failed -error: The argument '--port ' requires a value but none was supplied +error: the argument '--port ' requires a value but none was supplied [possible values: 22, 80] For more information try '--help' @@ -116,7 +116,7 @@ Args { optimization: None, include: None, bind: None, sleep: None, defines: [], $ typed-derive --log-level ? failed -error: The argument '--log-level ' requires a value but none was supplied +error: the argument '--log-level ' requires a value but none was supplied [possible values: info, debug, info, warn, error] For more information try '--help' diff --git a/src/derive.rs b/src/derive.rs index a5df2edc6cf..1abe0685182 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -385,7 +385,7 @@ pub trait ValueEnum: Sized + Clone { .matches(input, ignore_case) }) .cloned() - .ok_or_else(|| format!("Invalid variant: {}", input)) + .ok_or_else(|| format!("invalid variant: {}", input)) } /// The canonical argument value. diff --git a/src/error/format.rs b/src/error/format.rs index d82757d5cc3..fa021f396b4 100644 --- a/src/error/format.rs +++ b/src/error/format.rs @@ -36,7 +36,7 @@ impl ErrorFormatter for KindFormatter { } else if let Some(source) = error.inner.source.as_ref() { styled.none(source.to_string()); } else { - styled.none("Unknown cause"); + styled.none("unknown cause"); } styled.none("\n"); styled @@ -60,7 +60,7 @@ impl ErrorFormatter for RichFormatter { } else if let Some(source) = error.inner.source.as_ref() { styled.none(source.to_string()); } else { - styled.none("Unknown cause"); + styled.none("unknown cause"); } } @@ -129,11 +129,11 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> (invalid_arg, prior_arg) { if ContextValue::String(invalid_arg.clone()) == *prior_arg { - styled.none("The argument '"); + styled.none("the argument '"); styled.warning(invalid_arg); styled.none("' was provided more than once, but cannot be used multiple times"); } else { - styled.none("The argument '"); + styled.none("the argument '"); styled.warning(invalid_arg); styled.none("' cannot be used with"); @@ -164,7 +164,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ErrorKind::NoEquals => { let invalid_arg = error.get(ContextKind::InvalidArg); if let Some(ContextValue::String(invalid_arg)) = invalid_arg { - styled.none("Equal sign is needed when assigning values to '"); + styled.none("equal sign is needed when assigning values to '"); styled.warning(invalid_arg); styled.none("'"); true @@ -181,7 +181,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ) = (invalid_arg, invalid_value) { if invalid_value.is_empty() { - styled.none("The argument '"); + styled.none("the argument '"); styled.warning(invalid_arg); styled.none("' requires a value but none was supplied"); } else { @@ -216,7 +216,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ErrorKind::InvalidSubcommand => { let invalid_sub = error.get(ContextKind::InvalidSubcommand); if let Some(ContextValue::String(invalid_sub)) = invalid_sub { - styled.none("The subcommand '"); + styled.none("the subcommand '"); styled.warning(invalid_sub); styled.none("' wasn't recognized"); true @@ -227,7 +227,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ErrorKind::MissingRequiredArgument => { let invalid_arg = error.get(ContextKind::InvalidArg); if let Some(ContextValue::Strings(invalid_arg)) = invalid_arg { - styled.none("The following required arguments were not provided:"); + styled.none("the following required arguments were not provided:"); for v in invalid_arg { styled.none("\n"); styled.none(TAB); @@ -276,7 +276,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> Some(ContextValue::String(invalid_value)), ) = (invalid_arg, invalid_value) { - styled.none("The value '"); + styled.none("the value '"); styled.warning(invalid_value); styled.none("' was provided to '"); styled.warning(invalid_arg); @@ -297,7 +297,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ) = (invalid_arg, actual_num_values, min_values) { let were_provided = singular_or_plural(*actual_num_values as usize); - styled.none("The argument '"); + styled.none("the argument '"); styled.warning(invalid_arg); styled.none("' requires at least "); styled.warning(min_values.to_string()); @@ -317,7 +317,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> Some(ContextValue::String(invalid_value)), ) = (invalid_arg, invalid_value) { - styled.none("Invalid value '"); + styled.none("invalid value '"); styled.warning(invalid_value); styled.none("' for '"); styled.warning(invalid_arg); @@ -343,7 +343,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ) = (invalid_arg, actual_num_values, num_values) { let were_provided = singular_or_plural(*actual_num_values as usize); - styled.none("The argument '"); + styled.none("the argument '"); styled.warning(invalid_arg); styled.none("' requires "); styled.warning(num_values.to_string()); @@ -358,7 +358,7 @@ fn write_dynamic_context(error: &crate::error::Error, styled: &mut StyledStr) -> ErrorKind::UnknownArgument => { let invalid_arg = error.get(ContextKind::InvalidArg); if let Some(ContextValue::String(invalid_arg)) = invalid_arg { - styled.none("Found argument '"); + styled.none("found argument '"); styled.warning(invalid_arg.to_string()); styled.none("' which wasn't expected, or isn't valid in this context"); true diff --git a/src/error/kind.rs b/src/error/kind.rs index aa316ef30d1..4c254b446a9 100644 --- a/src/error/kind.rs +++ b/src/error/kind.rs @@ -82,7 +82,7 @@ pub enum ErrorKind { /// fn is_numeric(val: &str) -> Result<(), String> { /// match val.parse::() { /// Ok(..) => Ok(()), - /// Err(..) => Err(String::from("Value wasn't a number!")), + /// Err(..) => Err(String::from("value wasn't a number!")), /// } /// } /// @@ -316,24 +316,24 @@ impl ErrorKind { /// End-user description of the error case, where relevant pub fn as_str(self) -> Option<&'static str> { match self { - Self::InvalidValue => Some("One of the values isn't valid for an argument"), + Self::InvalidValue => Some("one of the values isn't valid for an argument"), Self::UnknownArgument => { - Some("Found an argument which wasn't expected or isn't valid in this context") + Some("found an argument which wasn't expected or isn't valid in this context") } - Self::InvalidSubcommand => Some("A subcommand wasn't recognized"), - Self::NoEquals => Some("Equal is needed when assigning values to one of the arguments"), - Self::ValueValidation => Some("Invalid value for one of the arguments"), - Self::TooManyValues => Some("An argument received an unexpected value"), - Self::TooFewValues => Some("An argument requires more values"), - Self::WrongNumberOfValues => Some("An argument received too many or too few values"), + Self::InvalidSubcommand => Some("a subcommand wasn't recognized"), + Self::NoEquals => Some("equal is needed when assigning values to one of the arguments"), + Self::ValueValidation => Some("invalid value for one of the arguments"), + Self::TooManyValues => Some("an argument received an unexpected value"), + Self::TooFewValues => Some("an argument requires more values"), + Self::WrongNumberOfValues => Some("an argument received too many or too few values"), Self::ArgumentConflict => { - Some("An argument cannot be used with one or more of the other specified arguments") + Some("an argument cannot be used with one or more of the other specified arguments") } Self::MissingRequiredArgument => { - Some("One or more required arguments were not provided") + Some("one or more required arguments were not provided") } - Self::MissingSubcommand => Some("A subcommand is required but one was not provided"), - Self::InvalidUtf8 => Some("Invalid UTF-8 was detected in one or more arguments"), + Self::MissingSubcommand => Some("a subcommand is required but one was not provided"), + Self::InvalidUtf8 => Some("invalid UTF-8 was detected in one or more arguments"), Self::DisplayHelp => None, Self::DisplayHelpOnMissingArgumentOrSubcommand => None, Self::DisplayVersion => None, diff --git a/src/util/color.rs b/src/util/color.rs index 7c7468eafd7..4d59b2eb288 100644 --- a/src/util/color.rs +++ b/src/util/color.rs @@ -82,7 +82,7 @@ impl std::str::FromStr for ColorChoice { return Ok(*variant); } } - Err(format!("Invalid variant: {}", s)) + Err(format!("invalid variant: {}", s)) } } diff --git a/tests/builder/conflicts.rs b/tests/builder/conflicts.rs index 048a7e3fad6..c14f6ea5838 100644 --- a/tests/builder/conflicts.rs +++ b/tests/builder/conflicts.rs @@ -321,7 +321,7 @@ fn get_arg_conflicts_with_group() { #[cfg(feature = "error-context")] fn conflict_output() { static CONFLICT_ERR: &str = "\ -error: The argument '--flag...' cannot be used with '-F' +error: the argument '--flag...' cannot be used with '-F' Usage: clap-test --flag... --long-option-2 [positional3]... @@ -340,7 +340,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn conflict_output_rev() { static CONFLICT_ERR_REV: &str = "\ -error: The argument '-F' cannot be used with '--flag...' +error: the argument '-F' cannot be used with '--flag...' Usage: clap-test -F --long-option-2 [positional3]... @@ -359,7 +359,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn conflict_output_repeat() { static ERR: &str = "\ -error: The argument '-F' was provided more than once, but cannot be used multiple times +error: the argument '-F' was provided more than once, but cannot be used multiple times Usage: clap-test [OPTIONS] [positional] [positional2] [positional3]... [COMMAND] @@ -373,7 +373,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn conflict_output_with_required() { static CONFLICT_ERR: &str = "\ -error: The argument '--flag...' cannot be used with '-F' +error: the argument '--flag...' cannot be used with '-F' Usage: clap-test --flag... --long-option-2 [positional3]... @@ -392,7 +392,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn conflict_output_rev_with_required() { static CONFLICT_ERR_REV: &str = "\ -error: The argument '-F' cannot be used with '--flag...' +error: the argument '-F' cannot be used with '--flag...' Usage: clap-test -F --long-option-2 [positional3]... @@ -411,7 +411,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn conflict_output_three_conflicting() { static CONFLICT_ERR_THREE: &str = "\ -error: The argument '--one' cannot be used with: +error: the argument '--one' cannot be used with: --two --three @@ -469,7 +469,7 @@ fn two_conflicting_arguments() { let a = a.unwrap_err(); assert!( a.to_string() - .contains("The argument \'--develop\' cannot be used with \'--production\'"), + .contains("the argument \'--develop\' cannot be used with \'--production\'"), "{}", a ); @@ -503,7 +503,7 @@ fn three_conflicting_arguments() { let a = a.unwrap_err(); assert!( a.to_string() - .contains("The argument \'--one\' cannot be used with:"), + .contains("the argument \'--one\' cannot be used with:"), "{}", a ); @@ -734,7 +734,7 @@ fn args_negate_subcommands_two_levels() { #[cfg(feature = "error-context")] fn subcommand_conflict_error_message() { static CONFLICT_ERR: &str = "\ -error: Found argument 'sub1' which wasn't expected, or isn't valid in this context +error: found argument 'sub1' which wasn't expected, or isn't valid in this context Usage: test [OPTIONS] test diff --git a/tests/builder/default_missing_vals.rs b/tests/builder/default_missing_vals.rs index 74ac98cae61..99deabd5347 100644 --- a/tests/builder/default_missing_vals.rs +++ b/tests/builder/default_missing_vals.rs @@ -277,7 +277,7 @@ fn default_missing_values_are_possible_values() { #[cfg(debug_assertions)] #[test] #[cfg(feature = "error-context")] -#[should_panic = "Argument `arg`'s default_missing_value=\"value\" failed validation: error: Invalid value 'value' for '[arg]"] +#[should_panic = "Argument `arg`'s default_missing_value=\"value\" failed validation: error: invalid value 'value' for '[arg]"] fn default_missing_values_are_valid() { use clap::{Arg, Command}; diff --git a/tests/builder/default_vals.rs b/tests/builder/default_vals.rs index d362134b6f1..51f2835e481 100644 --- a/tests/builder/default_vals.rs +++ b/tests/builder/default_vals.rs @@ -52,7 +52,7 @@ fn opt_without_value_fail() { assert_eq!(err.kind(), ErrorKind::InvalidValue); assert!(err .to_string() - .contains("The argument '-o ' requires a value but none was supplied")); + .contains("the argument '-o ' requires a value but none was supplied")); } #[test] @@ -730,7 +730,7 @@ fn default_vals_donnot_show_in_smart_usage() { cmd, "bug", "\ -error: The following required arguments were not provided: +error: the following required arguments were not provided: Usage: bug @@ -812,7 +812,7 @@ fn default_values_are_possible_values() { #[cfg(debug_assertions)] #[test] #[cfg(feature = "error-context")] -#[should_panic = "Argument `arg`'s default_value=\"one\" failed validation: error: Invalid value 'one' for '[arg]"] +#[should_panic = "Argument `arg`'s default_value=\"one\" failed validation: error: invalid value 'one' for '[arg]"] fn invalid_default_values() { use clap::{Arg, Command}; @@ -842,7 +842,7 @@ fn valid_delimited_default_values() { #[cfg(debug_assertions)] #[test] #[cfg(feature = "error-context")] -#[should_panic = "Argument `arg`'s default_value=\"one\" failed validation: error: Invalid value 'one' for '[arg]"] +#[should_panic = "Argument `arg`'s default_value=\"one\" failed validation: error: invalid value 'one' for '[arg]"] fn invalid_delimited_default_values() { use clap::{Arg, Command}; diff --git a/tests/builder/double_require.rs b/tests/builder/double_require.rs index fb16fe370cc..14a0c2034a3 100644 --- a/tests/builder/double_require.rs +++ b/tests/builder/double_require.rs @@ -59,7 +59,7 @@ fn help_text() { #[cfg(feature = "error-context")] fn no_duplicate_error() { static ONLY_B_ERROR: &str = "\ -error: The following required arguments were not provided: +error: the following required arguments were not provided: -c Usage: prog -b -c @@ -74,7 +74,7 @@ For more information try '--help' assert_eq!(err.to_string(), ONLY_B_ERROR); static ONLY_C_ERROR: &str = "\ -error: The following required arguments were not provided: +error: the following required arguments were not provided: -b Usage: prog -c -b diff --git a/tests/builder/empty_values.rs b/tests/builder/empty_values.rs index 1709a5d1963..f31788d4d87 100644 --- a/tests/builder/empty_values.rs +++ b/tests/builder/empty_values.rs @@ -118,7 +118,7 @@ fn no_empty_values_without_equals_but_requires_equals() { assert_eq!(m.unwrap_err().kind(), ErrorKind::NoEquals); static NO_EUQALS_ERROR: &str = - "error: Equal sign is needed when assigning values to '--config=' + "error: equal sign is needed when assigning values to '--config=' Usage: config [OPTIONS] diff --git a/tests/builder/error.rs b/tests/builder/error.rs index 47d2282aa34..b382bc20706 100644 --- a/tests/builder/error.rs +++ b/tests/builder/error.rs @@ -23,7 +23,7 @@ fn assert_error( #[test] fn app_error() { - static MESSAGE: &str = "error: Failed for mysterious reasons + static MESSAGE: &str = "error: failed for mysterious reasons Usage: test [OPTIONS] --all @@ -55,7 +55,7 @@ For more information try '--help' ); let mut cmd = cmd; let expected_kind = ErrorKind::InvalidValue; - let err = cmd.error(expected_kind, "Failed for mysterious reasons"); + let err = cmd.error(expected_kind, "failed for mysterious reasons"); assert_error(err, expected_kind, MESSAGE, true); } @@ -106,7 +106,7 @@ fn kind_formats_validation_error() { let err = res.unwrap_err(); let expected_kind = ErrorKind::UnknownArgument; static MESSAGE: &str = "\ -error: Found an argument which wasn't expected or isn't valid in this context +error: found an argument which wasn't expected or isn't valid in this context "; assert_error(err, expected_kind, MESSAGE, true); } @@ -120,7 +120,7 @@ fn rich_formats_validation_error() { let err = res.unwrap_err(); let expected_kind = ErrorKind::UnknownArgument; static MESSAGE: &str = "\ -error: Found argument 'unused' which wasn't expected, or isn't valid in this context +error: found argument 'unused' which wasn't expected, or isn't valid in this context Usage: test @@ -139,7 +139,7 @@ fn suggest_trailing() { let err = res.unwrap_err(); let expected_kind = ErrorKind::UnknownArgument; static MESSAGE: &str = "\ -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 note: to pass '--foo' as a value, use '-- --foo' @@ -160,7 +160,7 @@ fn trailing_already_in_use() { let err = res.unwrap_err(); let expected_kind = ErrorKind::UnknownArgument; static MESSAGE: &str = "\ -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: rg [PATTERN] @@ -179,7 +179,7 @@ fn cant_use_trailing() { let err = res.unwrap_err(); let expected_kind = ErrorKind::UnknownArgument; static MESSAGE: &str = "\ -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: test diff --git a/tests/builder/flags.rs b/tests/builder/flags.rs index 6aabeac93b6..fde1c3a8113 100644 --- a/tests/builder/flags.rs +++ b/tests/builder/flags.rs @@ -140,7 +140,7 @@ fn multiple_flags_in_single() { #[cfg(feature = "error-context")] fn unexpected_value_error() { const USE_FLAG_AS_ARGUMENT: &str = "\ -error: The value 'foo' was provided to '--a-flag' but it wasn't expecting any more values +error: the value 'foo' was provided to '--a-flag' but it wasn't expecting any more values Usage: mycat --a-flag [filename] @@ -158,7 +158,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn issue_1284_argument_in_flag_style() { const USE_FLAG_AS_ARGUMENT: &str = "\ -error: Found argument '--another-flag' which wasn't expected, or isn't valid in this context +error: found argument '--another-flag' which wasn't expected, or isn't valid in this context note: to pass '--another-flag' as a value, use '-- --another-flag' @@ -202,7 +202,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn issue_2308_multiple_dashes() { static MULTIPLE_DASHES: &str = "\ -error: Found argument '-----' which wasn't expected, or isn't valid in this context +error: found argument '-----' which wasn't expected, or isn't valid in this context note: to pass '-----' as a value, use '-- -----' diff --git a/tests/builder/groups.rs b/tests/builder/groups.rs index e2b77a46e73..61fd1f7d8be 100644 --- a/tests/builder/groups.rs +++ b/tests/builder/groups.rs @@ -131,7 +131,7 @@ fn empty_group() { #[test] #[cfg(feature = "error-context")] fn req_group_usage_string() { - static REQ_GROUP_USAGE: &str = "error: The following required arguments were not provided: + static REQ_GROUP_USAGE: &str = "error: the following required arguments were not provided: Usage: clap-test @@ -157,7 +157,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn req_group_with_conflict_usage_string() { static REQ_GROUP_CONFLICT_USAGE: &str = "\ -error: The argument '--delete' cannot be used with '[base]' +error: the argument '--delete' cannot be used with '[base]' Usage: clap-test @@ -187,7 +187,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn req_group_with_conflict_usage_string_only_options() { static REQ_GROUP_CONFLICT_ONLY_OPTIONS: &str = "\ -error: The argument '--delete' cannot be used with '--all' +error: the argument '--delete' cannot be used with '--all' Usage: clap-test <--all|--delete> @@ -305,7 +305,7 @@ fn group_acts_like_arg() { #[test] fn conflict_with_overlapping_group_in_error() { static ERR: &str = "\ -error: The argument '--major' cannot be used with '--minor' +error: the argument '--major' cannot be used with '--minor' Usage: prog --major @@ -324,7 +324,7 @@ For more information try '--help' #[test] fn requires_group_with_overlapping_group_in_error() { static ERR: &str = "\ -error: The following required arguments were not provided: +error: the following required arguments were not provided: <--in|--spec> Usage: prog --config <--in|--spec> diff --git a/tests/builder/help.rs b/tests/builder/help.rs index f4a68521ce1..6ee67b0d309 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -79,7 +79,7 @@ fn help_multi_subcommand_error() { .try_get_matches_from(["ctest", "help", "subcmd", "multi", "foo"]) .unwrap_err(); - static EXPECTED: &str = "error: The subcommand 'foo' wasn't recognized + static EXPECTED: &str = "error: the subcommand 'foo' wasn't recognized Usage: ctest subcmd multi [OPTIONS] diff --git a/tests/builder/opts.rs b/tests/builder/opts.rs index 1de0b753e51..4fa3ee5b33d 100644 --- a/tests/builder/opts.rs +++ b/tests/builder/opts.rs @@ -21,7 +21,7 @@ fn require_equals_fail() { #[test] #[cfg(feature = "error-context")] fn require_equals_fail_message() { - static NO_EQUALS: &str = "error: Equal sign is needed when assigning values to '--config=' + static NO_EQUALS: &str = "error: equal sign is needed when assigning values to '--config=' Usage: prog [OPTIONS] @@ -446,7 +446,7 @@ fn leading_hyphen_with_only_pos_follows() { #[cfg(feature = "error-context")] fn did_you_mean() { static DYM: &str = "\ -error: Found argument '--optio' which wasn't expected, or isn't valid in this context +error: found argument '--optio' which wasn't expected, or isn't valid in this context note: argument '--option' exists @@ -544,7 +544,7 @@ fn issue_1105_empty_value_short_explicit_no_space() { #[cfg(feature = "error-context")] fn issue_1073_suboptimal_flag_suggestion() { static DYM_ISSUE_1073: &str = "\ -error: Found argument '--files-without-matches' which wasn't expected, or isn't valid in this context +error: found argument '--files-without-matches' which wasn't expected, or isn't valid in this context note: argument '--files-without-match' exists diff --git a/tests/builder/possible_values.rs b/tests/builder/possible_values.rs index f6fc7a5724b..af43f63a3e3 100644 --- a/tests/builder/possible_values.rs +++ b/tests/builder/possible_values.rs @@ -322,7 +322,7 @@ For more information try '--help' #[cfg(feature = "error-context")] fn missing_possible_value_error() { static MISSING_PV_ERROR: &str = "\ -error: The argument '-O