From ea76fa1b1b273e65e3b0b1046643715b49bec51f Mon Sep 17 00:00:00 2001 From: Bruce Adams Date: Thu, 28 Jun 2018 02:12:58 -0400 Subject: [PATCH] Add a simple group example (#120) --- examples/simple_group.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/simple_group.rs diff --git a/examples/simple_group.rs b/examples/simple_group.rs new file mode 100644 index 00000000000..d3dd5464938 --- /dev/null +++ b/examples/simple_group.rs @@ -0,0 +1,31 @@ +#[macro_use] +extern crate structopt; + +use structopt::StructOpt; + +#[derive(StructOpt, Debug)] +struct Opt { + /// Set a custom HTTP verb + #[structopt(long = "method", group = "verb")] + method: Option, + /// HTTP GET; default if no other HTTP verb is selected + #[structopt(long = "get", group = "verb")] + get: bool, + /// HTTP HEAD + #[structopt(long = "head", group = "verb")] + head: bool, + /// HTTP POST + #[structopt(long = "post", group = "verb")] + post: bool, + /// HTTP PUT + #[structopt(long = "put", group = "verb")] + put: bool, + /// HTTP DELETE + #[structopt(long = "delete", group = "verb")] + delete: bool, +} + +fn main() { + let opt = Opt::from_args(); + println!("{:?}", opt); +}