1 //! How to use `clap::Arg::group`
2
3 use structopt::{clap::ArgGroup, StructOpt};
4
5 #[derive(StructOpt, Debug)]
6 #[structopt(group = ArgGroup::with_name("verb").required(true))]
7 struct Opt {
8 /// Set a custom HTTP verb
9 #[structopt(long, group = "verb")]
10 method: Option<String>,
11 /// HTTP GET
12 #[structopt(long, group = "verb")]
13 get: bool,
14 /// HTTP HEAD
15 #[structopt(long, group = "verb")]
16 head: bool,
17 /// HTTP POST
18 #[structopt(long, group = "verb")]
19 post: bool,
20 /// HTTP PUT
21 #[structopt(long, group = "verb")]
22 put: bool,
23 /// HTTP DELETE
24 #[structopt(long, group = "verb")]
25 delete: bool,
26 }
27
main()28 fn main() {
29 let opt = Opt::from_args();
30 println!("{:?}", opt);
31 }
32