diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:12:43 +0000 |
commit | cf94bdc0742c13e2a0cac864c478b8626b266e1b (patch) | |
tree | 044670aa50cc5e2b4229aa0b6b3df6676730c0a6 /vendor/xflags/src/rt.rs | |
parent | Adding debian version 1.65.0+dfsg1-2. (diff) | |
download | rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.tar.xz rustc-cf94bdc0742c13e2a0cac864c478b8626b266e1b.zip |
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/xflags/src/rt.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/vendor/xflags/src/rt.rs b/vendor/xflags/src/rt.rs index 3c33196af..988e6cc23 100644 --- a/vendor/xflags/src/rt.rs +++ b/vendor/xflags/src/rt.rs @@ -4,7 +4,7 @@ use crate::{Error, Result}; macro_rules! format_err { ($($tt:tt)*) => { - Error { msg: format!($($tt)*) } + Error { msg: format!($($tt)*), help: false } }; } @@ -94,6 +94,14 @@ impl Parser { format_err!("unexpected argument: {:?}", arg) } + pub fn subcommand_required(&self) -> Error { + format_err!("subcommand is required") + } + + pub fn help(&self, help: &'static str) -> Error { + Error { msg: help.to_string(), help: true } + } + pub fn optional<T>(&self, flag: &str, mut vals: Vec<T>) -> Result<Option<T>> { if vals.len() > 1 { bail!("flag specified more than once: `{}`", flag) @@ -107,8 +115,4 @@ impl Parser { } vals.pop().ok_or_else(|| format_err!("flag is required: `{}`", flag)) } - - pub fn subcommand<T>(&self, cmd: Option<T>) -> Result<T> { - cmd.ok_or_else(|| format_err!("subcommand is required")) - } } |