mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
31 lines
665 B
Rust
31 lines
665 B
Rust
//! How to use `clap::Arg::group`
|
|
|
|
use clap::{ArgGroup, Clap};
|
|
|
|
#[derive(Clap, Debug)]
|
|
#[clap(group = ArgGroup::with_name("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);
|
|
}
|