blob: 0bad2e649edefd8c139ed220e0e592b990f52deb [file] [log] [blame]
Matthew Maurer32e76692020-06-02 11:15:15 -07001//! How to extract subcommands' args into external structs.
2
3use structopt::StructOpt;
4
5#[derive(Debug, StructOpt)]
6pub struct Foo {
7 pub bar: Option<String>,
8}
9
10#[derive(Debug, StructOpt)]
11pub enum Command {
12 #[structopt(name = "foo")]
13 Foo(Foo),
14}
15
16#[derive(Debug, StructOpt)]
17#[structopt(name = "classify")]
18pub struct ApplicationArguments {
19 #[structopt(subcommand)]
20 pub command: Command,
21}
22
23fn main() {
24 let opt = ApplicationArguments::from_args();
25 println!("{:?}", opt);
26}