mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
style: rename ErrorKind::{VersionDisplayed, HelpDisplayed} to present tense
This commit is contained in:
parent
dc363d0b91
commit
866f2edbed
9 changed files with 30 additions and 30 deletions
|
@ -1655,7 +1655,7 @@ impl<'b> App<'b> {
|
||||||
///
|
///
|
||||||
/// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
|
/// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
|
||||||
/// used. It will return a [`clap::Error`], where the [`kind`] is a
|
/// used. It will return a [`clap::Error`], where the [`kind`] is a
|
||||||
/// [`ErrorKind::HelpDisplayed`] or [`ErrorKind::VersionDisplayed`] respectively. You must call
|
/// [`ErrorKind::DisplayHelp`] or [`ErrorKind::DisplayVersion`] respectively. You must call
|
||||||
/// [`Error::exit`] or perform a [`std::process::exit`].
|
/// [`Error::exit`] or perform a [`std::process::exit`].
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -1668,8 +1668,8 @@ impl<'b> App<'b> {
|
||||||
/// .unwrap_or_else(|e| e.exit());
|
/// .unwrap_or_else(|e| e.exit());
|
||||||
/// ```
|
/// ```
|
||||||
/// [`env::args_os`]: https://doc.rust-lang.org/std/env/fn.args_os.html
|
/// [`env::args_os`]: https://doc.rust-lang.org/std/env/fn.args_os.html
|
||||||
/// [`ErrorKind::HelpDisplayed`]: ./enum.ErrorKind.html#variant.HelpDisplayed
|
/// [`ErrorKind::DisplayHelp`]: ./enum.ErrorKind.html#variant.DisplayHelp
|
||||||
/// [`ErrorKind::VersionDisplayed`]: ./enum.ErrorKind.html#variant.VersionDisplayed
|
/// [`ErrorKind::DisplayVersion`]: ./enum.ErrorKind.html#variant.DisplayVersion
|
||||||
/// [`Error::exit`]: ./struct.Error.html#method.exit
|
/// [`Error::exit`]: ./struct.Error.html#method.exit
|
||||||
/// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
|
/// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
|
||||||
/// [`clap::Result`]: ./type.Result.html
|
/// [`clap::Result`]: ./type.Result.html
|
||||||
|
@ -1733,8 +1733,8 @@ impl<'b> App<'b> {
|
||||||
/// [`App::try_get_matches`]
|
/// [`App::try_get_matches`]
|
||||||
///
|
///
|
||||||
/// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
|
/// **NOTE:** This method WILL NOT exit when `--help` or `--version` (or short versions) are
|
||||||
/// used. It will return a [`clap::Error`], where the [`kind`] is a [`ErrorKind::HelpDisplayed`]
|
/// used. It will return a [`clap::Error`], where the [`kind`] is a [`ErrorKind::DisplayHelp`]
|
||||||
/// or [`ErrorKind::VersionDisplayed`] respectively. You must call [`Error::exit`] or
|
/// or [`ErrorKind::DisplayVersion`] respectively. You must call [`Error::exit`] or
|
||||||
/// perform a [`std::process::exit`] yourself.
|
/// perform a [`std::process::exit`] yourself.
|
||||||
///
|
///
|
||||||
/// **NOTE:** The first argument will be parsed as the binary name unless
|
/// **NOTE:** The first argument will be parsed as the binary name unless
|
||||||
|
@ -1753,8 +1753,8 @@ impl<'b> App<'b> {
|
||||||
/// ```
|
/// ```
|
||||||
/// [`App::get_matches_from`]: ./struct.App.html#method.get_matches_from
|
/// [`App::get_matches_from`]: ./struct.App.html#method.get_matches_from
|
||||||
/// [`App::try_get_matches`]: ./struct.App.html#method.try_get_matches
|
/// [`App::try_get_matches`]: ./struct.App.html#method.try_get_matches
|
||||||
/// [`ErrorKind::HelpDisplayed`]: ./enum.ErrorKind.html#variant.HelpDisplayed
|
/// [`ErrorKind::DisplayHelp`]: ./enum.ErrorKind.html#variant.DisplayHelp
|
||||||
/// [`ErrorKind::VersionDisplayed`]: ./enum.ErrorKind.html#variant.VersionDisplayed
|
/// [`ErrorKind::DisplayVersion`]: ./enum.ErrorKind.html#variant.DisplayVersion
|
||||||
/// [`Error::exit`]: ./struct.Error.html#method.exit
|
/// [`Error::exit`]: ./struct.Error.html#method.exit
|
||||||
/// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
|
/// [`std::process::exit`]: https://doc.rust-lang.org/std/process/fn.exit.html
|
||||||
/// [`clap::Error`]: ./struct.Error.html
|
/// [`clap::Error`]: ./struct.Error.html
|
||||||
|
|
|
@ -629,7 +629,7 @@ pub enum AppSettings {
|
||||||
/// "myprog", "test", "-h"
|
/// "myprog", "test", "-h"
|
||||||
/// ]);
|
/// ]);
|
||||||
/// assert!(res.is_err());
|
/// assert!(res.is_err());
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
/// ```
|
/// ```
|
||||||
/// [`SubCommand`]: ./struct.SubCommand.html
|
/// [`SubCommand`]: ./struct.SubCommand.html
|
||||||
/// [`App`]: ./struct.App.html
|
/// [`App`]: ./struct.App.html
|
||||||
|
@ -683,7 +683,7 @@ pub enum AppSettings {
|
||||||
/// "myprog", "test", "-V"
|
/// "myprog", "test", "-V"
|
||||||
/// ]);
|
/// ]);
|
||||||
/// assert!(res.is_err());
|
/// assert!(res.is_err());
|
||||||
/// assert_eq!(res.unwrap_err().kind, ErrorKind::VersionDisplayed);
|
/// assert_eq!(res.unwrap_err().kind, ErrorKind::DisplayVersion);
|
||||||
/// ```
|
/// ```
|
||||||
/// [``]: ./struct..html
|
/// [``]: ./struct..html
|
||||||
/// [`App`]: ./struct.App.html
|
/// [`App`]: ./struct.App.html
|
||||||
|
|
|
@ -336,9 +336,9 @@ pub enum ErrorKind {
|
||||||
/// let result = App::new("prog")
|
/// let result = App::new("prog")
|
||||||
/// .try_get_matches_from(vec!["prog", "--help"]);
|
/// .try_get_matches_from(vec!["prog", "--help"]);
|
||||||
/// assert!(result.is_err());
|
/// assert!(result.is_err());
|
||||||
/// assert_eq!(result.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
/// assert_eq!(result.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
/// ```
|
/// ```
|
||||||
HelpDisplayed,
|
DisplayHelp,
|
||||||
|
|
||||||
/// Not a true "error" as it means `--version` or similar was used.
|
/// Not a true "error" as it means `--version` or similar was used.
|
||||||
/// The message will be sent to `stdout`.
|
/// The message will be sent to `stdout`.
|
||||||
|
@ -350,9 +350,9 @@ pub enum ErrorKind {
|
||||||
/// let result = App::new("prog")
|
/// let result = App::new("prog")
|
||||||
/// .try_get_matches_from(vec!["prog", "--version"]);
|
/// .try_get_matches_from(vec!["prog", "--version"]);
|
||||||
/// assert!(result.is_err());
|
/// assert!(result.is_err());
|
||||||
/// assert_eq!(result.unwrap_err().kind, ErrorKind::VersionDisplayed);
|
/// assert_eq!(result.unwrap_err().kind, ErrorKind::DisplayVersion);
|
||||||
/// ```
|
/// ```
|
||||||
VersionDisplayed,
|
DisplayVersion,
|
||||||
|
|
||||||
/// Occurs when using the [`ArgMathes::value_of_t`] and friends to convert an argument value
|
/// Occurs when using the [`ArgMathes::value_of_t`] and friends to convert an argument value
|
||||||
/// into type `T`, but the argument you requested wasn't used. I.e. you asked for an argument
|
/// into type `T`, but the argument you requested wasn't used. I.e. you asked for an argument
|
||||||
|
@ -424,7 +424,7 @@ impl Error {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn use_stderr(&self) -> bool {
|
pub fn use_stderr(&self) -> bool {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => false,
|
ErrorKind::DisplayHelp | ErrorKind::DisplayVersion => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1765,7 +1765,7 @@ where
|
||||||
_ => ClapError {
|
_ => ClapError {
|
||||||
cause: String::new(),
|
cause: String::new(),
|
||||||
message: c,
|
message: c,
|
||||||
kind: ErrorKind::HelpDisplayed,
|
kind: ErrorKind::DisplayHelp,
|
||||||
info: None,
|
info: None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1781,7 +1781,7 @@ where
|
||||||
_ => ClapError {
|
_ => ClapError {
|
||||||
cause: String::new(),
|
cause: String::new(),
|
||||||
message: c,
|
message: c,
|
||||||
kind: ErrorKind::VersionDisplayed,
|
kind: ErrorKind::DisplayVersion,
|
||||||
info: None,
|
info: None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn app_from_crate() {
|
||||||
|
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err = res.unwrap_err();
|
let err = res.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::HelpDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayHelp);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
EVERYTHING.replace("{{version}}", env!("CARGO_PKG_VERSION"))
|
EVERYTHING.replace("{{version}}", env!("CARGO_PKG_VERSION"))
|
||||||
|
|
|
@ -30,7 +30,7 @@ fn crate_version() {
|
||||||
|
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err = res.unwrap_err();
|
let err = res.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayVersion);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
format!("prog {}\n", env!("CARGO_PKG_VERSION"))
|
format!("prog {}\n", env!("CARGO_PKG_VERSION"))
|
||||||
|
@ -46,7 +46,7 @@ fn crate_description() {
|
||||||
|
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err = res.unwrap_err();
|
let err = res.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::HelpDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayHelp);
|
||||||
assert_eq!(err.to_string(), DESCRIPTION_ONLY);
|
assert_eq!(err.to_string(), DESCRIPTION_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ fn crate_authors() {
|
||||||
|
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err = res.unwrap_err();
|
let err = res.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::HelpDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayHelp);
|
||||||
assert_eq!(err.to_string(), AUTHORS_ONLY);
|
assert_eq!(err.to_string(), AUTHORS_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,6 @@ fn crate_name() {
|
||||||
|
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err = res.unwrap_err();
|
let err = res.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayVersion);
|
||||||
assert_eq!(err.to_string(), "clap \n");
|
assert_eq!(err.to_string(), "clap \n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,7 +594,7 @@ fn help_short() {
|
||||||
let m = setup().try_get_matches_from(vec!["myprog", "-h"]);
|
let m = setup().try_get_matches_from(vec!["myprog", "-h"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -602,7 +602,7 @@ fn help_long() {
|
||||||
let m = setup().try_get_matches_from(vec!["myprog", "--help"]);
|
let m = setup().try_get_matches_from(vec!["myprog", "--help"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -624,7 +624,7 @@ fn help_subcommand() {
|
||||||
.try_get_matches_from(vec!["myprog", "help"]);
|
.try_get_matches_from(vec!["myprog", "help"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -696,7 +696,7 @@ fn subcommand_short_help() {
|
||||||
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "-h"]);
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "-h"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -704,7 +704,7 @@ fn subcommand_long_help() {
|
||||||
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "--help"]);
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "--help"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -712,7 +712,7 @@ fn subcommand_help_rev() {
|
||||||
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "help", "subcmd"]);
|
let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "help", "subcmd"]);
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -245,7 +245,7 @@ fn alias_help() {
|
||||||
.subcommand(App::new("test").alias("do-stuff"))
|
.subcommand(App::new("test").alias("do-stuff"))
|
||||||
.try_get_matches_from(vec!["myprog", "help", "do-stuff"]);
|
.try_get_matches_from(vec!["myprog", "help", "do-stuff"]);
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::DisplayHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn version_short() {
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
let err = m.unwrap_err();
|
let err = m.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayVersion);
|
||||||
assert_eq!(err.to_string(), "test 1.3\n");
|
assert_eq!(err.to_string(), "test 1.3\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ fn version_long() {
|
||||||
|
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
let err = m.unwrap_err();
|
let err = m.unwrap_err();
|
||||||
assert_eq!(err.kind, ErrorKind::VersionDisplayed);
|
assert_eq!(err.kind, ErrorKind::DisplayVersion);
|
||||||
assert_eq!(err.to_string(), "test 1.3\n");
|
assert_eq!(err.to_string(), "test 1.3\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue