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:13:23 +0000 |
commit | 20431706a863f92cb37dc512fef6e48d192aaf2c (patch) | |
tree | 2867f13f5fd5437ba628c67d7f87309ccadcd286 /vendor/xflags/examples | |
parent | Releasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.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/examples/hello-generated.rs | 13 | ||||
-rw-r--r-- | vendor/xflags/examples/hello.rs | 3 | ||||
-rw-r--r-- | vendor/xflags/examples/immediate-mode.rs | 16 | ||||
-rw-r--r-- | vendor/xflags/examples/longer.rs | 7 | ||||
-rw-r--r-- | vendor/xflags/examples/non-utf8.rs | 3 |
5 files changed, 26 insertions, 16 deletions
diff --git a/vendor/xflags/examples/hello-generated.rs b/vendor/xflags/examples/hello-generated.rs index b82884859..cb74acbd7 100644 --- a/vendor/xflags/examples/hello-generated.rs +++ b/vendor/xflags/examples/hello-generated.rs @@ -5,10 +5,10 @@ mod flags { src "./examples/hello-generated.rs" /// Prints a greeting. - cmd hello + cmd hello { /// Whom to greet. required name: String - { + /// Use non-ascii symbols in the output. optional -e, --emoji } @@ -25,12 +25,12 @@ mod flags { } impl Hello { - pub const HELP: &'static str = Self::HELP_; - + #[allow(dead_code)] pub fn from_env() -> xflags::Result<Self> { Self::from_env_() } + #[allow(dead_code)] pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> { Self::from_vec_(args) } @@ -44,9 +44,6 @@ fn main() { let bang = if flags.emoji { "❣️" } else { "!" }; println!("Hello {}{}", flags.name, bang); } - Err(err) => { - eprintln!("{}\n\n{}", err, flags::Hello::HELP); - std::process::exit(1) - } + Err(err) => err.exit(), } } diff --git a/vendor/xflags/examples/hello.rs b/vendor/xflags/examples/hello.rs index 98a19099f..91dc3fd8a 100644 --- a/vendor/xflags/examples/hello.rs +++ b/vendor/xflags/examples/hello.rs @@ -1,8 +1,7 @@ mod flags { xflags::xflags! { - cmd hello + cmd hello { required name: String - { optional -e, --emoji } } diff --git a/vendor/xflags/examples/immediate-mode.rs b/vendor/xflags/examples/immediate-mode.rs new file mode 100644 index 000000000..ee3baa3de --- /dev/null +++ b/vendor/xflags/examples/immediate-mode.rs @@ -0,0 +1,16 @@ +use std::path::PathBuf; + +fn main() { + let flags = xflags::parse_or_exit! { + /// Remove directories and their contents recursively. + optional -r,--recursive + /// File or directory to remove + required path: PathBuf + }; + + println!( + "removing {}{}", + flags.path.display(), + if flags.recursive { "recursively" } else { "" }, + ) +} diff --git a/vendor/xflags/examples/longer.rs b/vendor/xflags/examples/longer.rs index 7ea9e18d5..199cca042 100644 --- a/vendor/xflags/examples/longer.rs +++ b/vendor/xflags/examples/longer.rs @@ -24,10 +24,9 @@ mod flags { } /// Benchmark specific analysis operation - cmd analysis-bench + cmd analysis-bench { /// Directory with Cargo.toml optional path: PathBuf - { /// Compute syntax highlighting for this file required --highlight path: PathBuf /// Compute highlighting for this line @@ -72,12 +71,12 @@ mod flags { } impl RustAnalyzer { - pub const HELP: &'static str = Self::HELP_; - + #[allow(dead_code)] pub fn from_env() -> xflags::Result<Self> { Self::from_env_() } + #[allow(dead_code)] pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> { Self::from_vec_(args) } diff --git a/vendor/xflags/examples/non-utf8.rs b/vendor/xflags/examples/non-utf8.rs index d355b24f6..28b1e98be 100644 --- a/vendor/xflags/examples/non-utf8.rs +++ b/vendor/xflags/examples/non-utf8.rs @@ -4,11 +4,10 @@ mod flags { use std::{ffi::OsString, path::PathBuf}; xflags::xflags! { - cmd Cmd + cmd Cmd { required a: OsString required b: PathBuf required c: String - { } } } |