diff options
author | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-07-19 15:37:58 +0300 |
commit | a990de90fe41456a23e58bd087d2f107d321f3a1 (patch) | |
tree | 15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/clap/examples/derive_ref/flatten_hand_args.rs | |
parent | 3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff) | |
download | fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip |
Deleted vendor folder
Diffstat (limited to 'vendor/clap/examples/derive_ref/flatten_hand_args.rs')
-rw-r--r-- | vendor/clap/examples/derive_ref/flatten_hand_args.rs | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/vendor/clap/examples/derive_ref/flatten_hand_args.rs b/vendor/clap/examples/derive_ref/flatten_hand_args.rs deleted file mode 100644 index 36aac09..0000000 --- a/vendor/clap/examples/derive_ref/flatten_hand_args.rs +++ /dev/null @@ -1,91 +0,0 @@ -use clap::error::Error; -use clap::{Arg, ArgAction, ArgMatches, Args, Command, FromArgMatches, Parser}; - -#[derive(Debug)] -struct CliArgs { - foo: bool, - bar: bool, - quuz: Option<String>, -} - -impl FromArgMatches for CliArgs { - fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error> { - let mut matches = matches.clone(); - Self::from_arg_matches_mut(&mut matches) - } - fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error> { - Ok(Self { - foo: matches.get_flag("foo"), - bar: matches.get_flag("bar"), - quuz: matches.remove_one::<String>("quuz"), - }) - } - fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error> { - let mut matches = matches.clone(); - self.update_from_arg_matches_mut(&mut matches) - } - fn update_from_arg_matches_mut(&mut self, matches: &mut ArgMatches) -> Result<(), Error> { - self.foo |= matches.get_flag("foo"); - self.bar |= matches.get_flag("bar"); - if let Some(quuz) = matches.remove_one::<String>("quuz") { - self.quuz = Some(quuz); - } - Ok(()) - } -} - -impl Args for CliArgs { - fn augment_args(cmd: Command) -> Command { - cmd.arg( - Arg::new("foo") - .short('f') - .long("foo") - .action(ArgAction::SetTrue), - ) - .arg( - Arg::new("bar") - .short('b') - .long("bar") - .action(ArgAction::SetTrue), - ) - .arg( - Arg::new("quuz") - .short('q') - .long("quuz") - .action(ArgAction::Set), - ) - } - fn augment_args_for_update(cmd: Command) -> Command { - cmd.arg( - Arg::new("foo") - .short('f') - .long("foo") - .action(ArgAction::SetTrue), - ) - .arg( - Arg::new("bar") - .short('b') - .long("bar") - .action(ArgAction::SetTrue), - ) - .arg( - Arg::new("quuz") - .short('q') - .long("quuz") - .action(ArgAction::Set), - ) - } -} - -#[derive(Parser, Debug)] -struct Cli { - #[arg(short, long)] - top_level: bool, - #[command(flatten)] - more_args: CliArgs, -} - -fn main() { - let args = Cli::parse(); - println!("{args:#?}"); -} |