summaryrefslogtreecommitdiffstats
path: root/vendor/xflags/src/rt.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/xflags/src/rt.rs14
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"))
- }
}