diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/xflags | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/xflags')
-rw-r--r-- | vendor/xflags/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/xflags/Cargo.lock | 6 | ||||
-rw-r--r-- | vendor/xflags/Cargo.toml | 4 | ||||
-rw-r--r-- | vendor/xflags/src/rt.rs | 58 |
4 files changed, 35 insertions, 35 deletions
diff --git a/vendor/xflags/.cargo-checksum.json b/vendor/xflags/.cargo-checksum.json index 1fa4dd9e5..ccb82afb6 100644 --- a/vendor/xflags/.cargo-checksum.json +++ b/vendor/xflags/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"bff2ffbef3ca253bcde1624bfc2c2afd244ca39b44e7dd3f4b463873904129c7","Cargo.toml":"faa866c2c32635dfa6d600103595777c330520df5e73aa0461d6f34eb21bbd9a","examples/hello-generated.rs":"3bf7922435ae84e2b8ae022aba1d693fc4e523b354d3141cc62a183864531f31","examples/hello.rs":"235426d1a69eeba790d1e4fc2ac4fa8f30ca16952edb2a026cf6f4b8c78d6fec","examples/immediate-mode.rs":"dcae135769b6104801de7b91fd220fb28ddae097ba7b0474fe32c28a90c4dfef","examples/longer.rs":"b55684fdde16a8462e1c1afaa9f30e75e3472abfcabe950403733c767dd7de96","examples/non-utf8.rs":"23b563180d1d616f81e224890192799a06fdbc21f3ccb7e4234ca51b3c467a9a","src/lib.rs":"780d7be977abefaa4c7229733a916d88480c9228ddb0f9bc2a25aaa626f7f7d7","src/rt.rs":"b80e6b1e180b0bd0fd523a6bc74d6bba40da7af461de37c33c3735bfb3c66254"},"package":"cbf19f5031a1a812e96fede16f8161218883079946cea87619d3613db1efd268"}
\ No newline at end of file +{"files":{"Cargo.lock":"29daddfd833005b0bce977a938c88f5d48e1e7f2112950b266719c0d9c30de87","Cargo.toml":"027201abeeab5b32f12827e94aa78a9e96e43e9c59aa99b1f038949103e1fdd9","examples/hello-generated.rs":"3bf7922435ae84e2b8ae022aba1d693fc4e523b354d3141cc62a183864531f31","examples/hello.rs":"235426d1a69eeba790d1e4fc2ac4fa8f30ca16952edb2a026cf6f4b8c78d6fec","examples/immediate-mode.rs":"dcae135769b6104801de7b91fd220fb28ddae097ba7b0474fe32c28a90c4dfef","examples/longer.rs":"b55684fdde16a8462e1c1afaa9f30e75e3472abfcabe950403733c767dd7de96","examples/non-utf8.rs":"23b563180d1d616f81e224890192799a06fdbc21f3ccb7e4234ca51b3c467a9a","src/lib.rs":"780d7be977abefaa4c7229733a916d88480c9228ddb0f9bc2a25aaa626f7f7d7","src/rt.rs":"be5393c690afde9c8c31b01471100eec21742f735983ef9074c3675daf942ac7"},"package":"c4554b580522d0ca238369c16b8f6ce34524d61dafe7244993754bbd05f2c2ea"}
\ No newline at end of file diff --git a/vendor/xflags/Cargo.lock b/vendor/xflags/Cargo.lock index e2020eb16..d4df44759 100644 --- a/vendor/xflags/Cargo.lock +++ b/vendor/xflags/Cargo.lock @@ -4,13 +4,13 @@ version = 3 [[package]] name = "xflags" -version = "0.3.0" +version = "0.3.1" dependencies = [ "xflags-macros", ] [[package]] name = "xflags-macros" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2afbd7f2039bb6cad2dd45f0c5dff49c0d4e26118398768b7a605524d4251809" +checksum = "f58e7b3ca8977093aae6b87b6a7730216fc4c53a6530bab5c43a783cd810c1a8" diff --git a/vendor/xflags/Cargo.toml b/vendor/xflags/Cargo.toml index 091002385..3db90b6be 100644 --- a/vendor/xflags/Cargo.toml +++ b/vendor/xflags/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2021" name = "xflags" -version = "0.3.0" +version = "0.3.1" authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"] description = "Moderately simple command line arguments parser." categories = ["command-line-interface"] @@ -21,4 +21,4 @@ repository = "https://github.com/matklad/xflags" resolver = "1" [dependencies.xflags-macros] -version = "=0.3.0" +version = "=0.3.1" diff --git a/vendor/xflags/src/rt.rs b/vendor/xflags/src/rt.rs index 988e6cc23..0b3d98c2b 100644 --- a/vendor/xflags/src/rt.rs +++ b/vendor/xflags/src/rt.rs @@ -15,36 +15,41 @@ macro_rules! bail { } pub struct Parser { + after_double_dash: bool, rargs: Vec<OsString>, } impl Parser { pub fn new(mut args: Vec<OsString>) -> Self { args.reverse(); - Self { rargs: args } + Self { after_double_dash: false, rargs: args } } pub fn new_from_env() -> Self { - let mut args = std::env::args_os().collect::<Vec<_>>(); - args.reverse(); - args.pop(); - Self { rargs: args } - } - - pub fn is_empty(&self) -> bool { - self.rargs.is_empty() + let args = std::env::args_os().collect::<Vec<_>>(); + let mut res = Parser::new(args); + let _progn = res.next(); + res } - pub fn peek_flag(&self) -> Option<&str> { - self.rargs.last().and_then(|it| it.to_str()).filter(|it| it.starts_with('-')) - } pub fn pop_flag(&mut self) -> Option<Result<String, OsString>> { - if self.peek_flag().is_some() { - self.next().map(|it| it.into_string()) - } else { + if self.after_double_dash { self.next().map(Err) + } else { + let arg = self.next()?; + let arg_str = arg.to_str().unwrap_or_default(); + if arg_str.starts_with('-') { + if arg_str == "--" { + self.after_double_dash = true; + return self.next().map(Err); + } + Some(arg.into_string()) + } else { + Some(Err(arg)) + } } } + pub fn push_back(&mut self, arg: Result<String, OsString>) { let arg = match arg { Ok(it) => it.into(), @@ -53,15 +58,12 @@ impl Parser { self.rargs.push(arg) } - pub fn next(&mut self) -> Option<OsString> { + fn next(&mut self) -> Option<OsString> { self.rargs.pop() } pub fn next_value(&mut self, flag: &str) -> Result<OsString> { - if self.peek_flag().is_some() { - bail!("expected a value for `{}`", flag) - } - self.next().ok_or_else(|| format_err!("expected a value for `{}`", flag)) + self.next().ok_or_else(|| format_err!("expected a value for `{flag}`")) } pub fn next_value_from_str<T: FromStr>(&mut self, flag: &str) -> Result<T> @@ -77,21 +79,19 @@ impl Parser { T::Err: fmt::Display, { match value.into_string() { - Ok(str) => { - str.parse::<T>().map_err(|err| format_err!("can't parse `{}`, {}", flag, err)) - } + Ok(str) => str.parse::<T>().map_err(|err| format_err!("can't parse `{flag}`, {err}")), Err(it) => { - bail!("can't parse `{}`, invalid utf8: {:?}", flag, it) + bail!("can't parse `{flag}`, invalid utf8: {it:?}") } } } pub fn unexpected_flag(&self, flag: &str) -> Error { - format_err!("unexpected flag: `{}`", flag) + format_err!("unexpected flag: `{flag}`") } pub fn unexpected_arg(&self, arg: OsString) -> Error { - format_err!("unexpected argument: {:?}", arg) + format_err!("unexpected argument: {arg:?}") } pub fn subcommand_required(&self) -> Error { @@ -104,15 +104,15 @@ impl Parser { 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) + bail!("flag specified more than once: `{flag}`") } Ok(vals.pop()) } pub fn required<T>(&self, flag: &str, mut vals: Vec<T>) -> Result<T> { if vals.len() > 1 { - bail!("flag specified more than once: `{}`", flag) + bail!("flag specified more than once: `{flag}`") } - vals.pop().ok_or_else(|| format_err!("flag is required: `{}`", flag)) + vals.pop().ok_or_else(|| format_err!("flag is required: `{flag}`")) } } |