clap/clap_derive/examples/group.rs
2020-05-14 22:50:56 +02:00

31 lines
659 B
Rust

//! How to use `clap::Arg::group`
use clap::{ArgGroup, Clap};
#[derive(Clap, Debug)]
#[clap(group = ArgGroup::new("verb").required(true))]
struct Opt {
/// Set a custom HTTP verb
#[clap(long, group = "verb")]
method: Option<String>,
/// HTTP GET
#[clap(long, group = "verb")]
get: bool,
/// HTTP HEAD
#[clap(long, group = "verb")]
head: bool,
/// HTTP POST
#[clap(long, group = "verb")]
post: bool,
/// HTTP PUT
#[clap(long, group = "verb")]
put: bool,
/// HTTP DELETE
#[clap(long, group = "verb")]
delete: bool,
}
fn main() {
let opt = Opt::parse();
println!("{:?}", opt);
}