2020-01-07 10:17:23 +00:00
|
|
|
//! How to use `clap::Arg::group`
|
2018-04-18 16:53:51 +00:00
|
|
|
|
2021-07-13 17:50:55 +00:00
|
|
|
use clap::{ArgGroup, Parser};
|
2018-04-18 16:53:51 +00:00
|
|
|
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Parser, Debug)]
|
2020-05-14 20:50:56 +00:00
|
|
|
#[clap(group = ArgGroup::new("verb").required(true))]
|
2018-04-18 16:53:51 +00:00
|
|
|
struct Opt {
|
2020-01-07 10:17:23 +00:00
|
|
|
/// 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,
|
2018-04-18 16:53:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-07-02 18:45:17 +00:00
|
|
|
let opt = Opt::parse();
|
2018-04-18 16:53:51 +00:00
|
|
|
println!("{:?}", opt);
|
|
|
|
}
|