From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- .../examples/tutorial_derive/04_03_relations.rs | 75 ---------------------- 1 file changed, 75 deletions(-) delete mode 100644 vendor/clap/examples/tutorial_derive/04_03_relations.rs (limited to 'vendor/clap/examples/tutorial_derive/04_03_relations.rs') diff --git a/vendor/clap/examples/tutorial_derive/04_03_relations.rs b/vendor/clap/examples/tutorial_derive/04_03_relations.rs deleted file mode 100644 index 8657ebe..0000000 --- a/vendor/clap/examples/tutorial_derive/04_03_relations.rs +++ /dev/null @@ -1,75 +0,0 @@ -use clap::{Args, Parser}; - -#[derive(Parser)] -#[command(author, version, about, long_about = None)] -struct Cli { - #[command(flatten)] - vers: Vers, - - /// some regular input - #[arg(group = "input")] - input_file: Option, - - /// some special input argument - #[arg(long, group = "input")] - spec_in: Option, - - #[arg(short, requires = "input")] - config: Option, -} - -#[derive(Args)] -#[group(required = true, multiple = false)] -struct Vers { - /// set version manually - #[arg(long, value_name = "VER")] - set_ver: Option, - - /// auto inc major - #[arg(long)] - major: bool, - - /// auto inc minor - #[arg(long)] - minor: bool, - - /// auto inc patch - #[arg(long)] - patch: bool, -} - -fn main() { - let cli = Cli::parse(); - - // Let's assume the old version 1.2.3 - let mut major = 1; - let mut minor = 2; - let mut patch = 3; - - // See if --set_ver was used to set the version manually - let vers = &cli.vers; - let version = if let Some(ver) = vers.set_ver.as_deref() { - ver.to_string() - } else { - // Increment the one requested (in a real program, we'd reset the lower numbers) - let (maj, min, pat) = (vers.major, vers.minor, vers.patch); - match (maj, min, pat) { - (true, _, _) => major += 1, - (_, true, _) => minor += 1, - (_, _, true) => patch += 1, - _ => unreachable!(), - }; - format!("{major}.{minor}.{patch}") - }; - - println!("Version: {version}"); - - // Check for usage of -c - if let Some(config) = cli.config.as_deref() { - let input = cli - .input_file - .as_deref() - .unwrap_or_else(|| cli.spec_in.as_deref().unwrap()); - println!("Doing work using input {input} and config {config}"); - } -} -- cgit v1.2.3