From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/xflags/examples/hello-generated.rs | 13 +++++-------- vendor/xflags/examples/hello.rs | 3 +-- vendor/xflags/examples/immediate-mode.rs | 16 ++++++++++++++++ vendor/xflags/examples/longer.rs | 7 +++---- vendor/xflags/examples/non-utf8.rs | 3 +-- 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 vendor/xflags/examples/immediate-mode.rs (limited to 'vendor/xflags/examples') 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::from_env_() } + #[allow(dead_code)] pub fn from_vec(args: Vec) -> xflags::Result { 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::from_env_() } + #[allow(dead_code)] pub fn from_vec(args: Vec) -> xflags::Result { 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 - { } } } -- cgit v1.2.3