Upgrade rust/crates/structopt to 0.3.20
Test: make
Change-Id: I50a53b96c652aea7c84a572a87578cf3828c00e2
diff --git a/src/lib.rs b/src/lib.rs
old mode 100644
new mode 100755
index c51277a..fb4ad85
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -309,7 +309,7 @@
//!
//! Usable only on field-level.
//!
-//! - [`rename_all_env`](##auto-deriving-environment-variables):
+//! - [`rename_all_env`](#auto-deriving-environment-variables):
//! [`rename_all_env = "kebab"/"snake"/"screaming-snake"/"camel"/"pascal"/"verbatim"/"lower"/"upper"]`
//!
//! Usable both on top level and field level.
@@ -533,7 +533,7 @@
//!
//! ### `long_help` and `--help`
//!
-//! A message passed to [`App::long_help`] or [`Arg::long_about`] will be displayed whenever
+//! A message passed to [`App::long_about`] or [`Arg::long_help`] will be displayed whenever
//! your program is called with `--help` instead of `-h`. Of course, you can
//! use them via raw methods as described [above](#help-messages).
//!
@@ -586,8 +586,8 @@
//!
//! The `-h` flag is not the same as `--help`.
//!
-//! -h corresponds to Arg::help/App::about and requests short "summary" messages
-//! while --help corresponds to Arg::long_help/App::long_about and requests more
+//! -h corresponds to `Arg::help/App::about` and requests short "summary" messages
+//! while --help corresponds to `Arg::long_help/App::long_about` and requests more
//! detailed, descriptive messages.
//!
//! It is entirely up to `clap` what happens if you used only one of
@@ -1073,15 +1073,16 @@
/// A struct that is converted from command line arguments.
pub trait StructOpt {
- /// Returns the corresponding `clap::App`.
+ /// Returns [`clap::App`] corresponding to the struct.
fn clap<'a, 'b>() -> clap::App<'a, 'b>;
- /// Creates the struct from `clap::ArgMatches`. It cannot fail
- /// with a parameter generated by `clap` by construction.
+ /// Builds the struct from [`clap::ArgMatches`]. It's guaranteed to succeed
+ /// if `matches` originates from an `App` generated by [`StructOpt::clap`] called on
+ /// the same type, otherwise it must panic.
fn from_clap(matches: &clap::ArgMatches<'_>) -> Self;
- /// Gets the struct from the command line arguments. Print the
- /// error message and quit the program in case of failure.
+ /// Builds the struct from the command line arguments ([`std::env::args_os`]).
+ /// Calls [`clap::Error::exit`] on failure, printing the error message and aborting the program.
fn from_args() -> Self
where
Self: Sized,
@@ -1089,13 +1090,23 @@
Self::from_clap(&Self::clap().get_matches())
}
+ /// Builds the struct from the command line arguments ([`std::env::args_os`]).
+ /// Unlike [`StructOpt::from_args`], returns [`clap::Error`] on failure instead of aborting the program,
+ /// so calling [`.exit`][clap::Error::exit] is up to you.
+ fn from_args_safe() -> Result<Self, clap::Error>
+ where
+ Self: Sized,
+ {
+ Self::clap()
+ .get_matches_safe()
+ .map(|matches| Self::from_clap(&matches))
+ }
+
/// Gets the struct from any iterator such as a `Vec` of your making.
/// Print the error message and quit the program in case of failure.
///
/// **NOTE**: The first argument will be parsed as the binary name unless
- /// [`AppSettings::NoBinaryName`] has been used.
- ///
- /// [`AppSettings::NoBinaryName`]: https://docs.rs/clap/2.33.0/clap/enum.AppSettings.html#variant.NoBinaryName
+ /// [`clap::AppSettings::NoBinaryName`] has been used.
fn from_iter<I>(iter: I) -> Self
where
Self: Sized,
@@ -1107,14 +1118,12 @@
/// Gets the struct from any iterator such as a `Vec` of your making.
///
- /// Returns a `clap::Error` in case of failure. This does *not* exit in the
+ /// Returns a [`clap::Error`] in case of failure. This does *not* exit in the
/// case of `--help` or `--version`, to achieve the same behavior as
- /// `from_iter()` you must call `.exit()` on the error value.
+ /// [`from_iter()`][StructOpt::from_iter] you must call [`.exit()`][clap::Error::exit] on the error value.
///
/// **NOTE**: The first argument will be parsed as the binary name unless
- /// [`AppSettings::NoBinaryName`] has been used.
- ///
- /// [`AppSettings::NoBinaryName`]: https://docs.rs/clap/2.33.0/clap/enum.AppSettings.html#variant.NoBinaryName
+ /// [`clap::AppSettings::NoBinaryName`] has been used.
fn from_iter_safe<I>(iter: I) -> Result<Self, clap::Error>
where
Self: Sized,