clap/examples/simple_group.rs

32 lines
690 B
Rust
Raw Normal View History

2018-06-28 06:12:58 +00:00
#[macro_use]
extern crate clap;
2018-06-28 06:12:58 +00:00
use clap::Clap;
2018-06-28 06:12:58 +00:00
#[derive(Clap, Debug)]
2018-06-28 06:12:58 +00:00
struct Opt {
/// Set a custom HTTP verb
#[clap(long = "method", group = "verb")]
2018-06-28 06:12:58 +00:00
method: Option<String>,
/// HTTP GET; default if no other HTTP verb is selected
#[clap(long = "get", group = "verb")]
2018-06-28 06:12:58 +00:00
get: bool,
/// HTTP HEAD
#[clap(long = "head", group = "verb")]
2018-06-28 06:12:58 +00:00
head: bool,
/// HTTP POST
#[clap(long = "post", group = "verb")]
2018-06-28 06:12:58 +00:00
post: bool,
/// HTTP PUT
#[clap(long = "put", group = "verb")]
2018-06-28 06:12:58 +00:00
put: bool,
/// HTTP DELETE
#[clap(long = "delete", group = "verb")]
2018-06-28 06:12:58 +00:00
delete: bool,
}
fn main() {
let opt = Opt::parse();
2018-06-28 06:12:58 +00:00
println!("{:?}", opt);
}