title: How to use an enum that represents subcommands with StructOpt?
body: <p>Referring to the <a href="https://docs.rs/structopt/0.2.8/structopt/#subcommands" rel="noreferrer">"Git" example of StructOpt</a>, I do not understand how I am then supposed to use the data from the arguments.</p>
  
  <p>I am fairly new to Rust so I am guessing it is obvious. Unfortunately, all examples I can find with an enum only do a <code>println!</code> on the object so I am stuck. I thought I'd do a <code>match</code> but it does not work.</p>
  
  <p>How would you then find which commands was passed by the user to run your program?</p>
  
  <pre><code>#[macro_use]
  extern crate structopt;
  
  use std::path::PathBuf;
  use structopt::StructOpt;
  
  #[derive(StructOpt, Debug)]
  #[structopt(name = "git", about = "the stupid content tracker")]
  enum Git {
      #[structopt(name = "add")]
      Add {
          #[structopt(short = "i")]
          interactive: bool,
          #[structopt(short = "p")]
          patch: bool,
          #[structopt(parse(from_os_str))]
          files: Vec&lt;PathBuf&gt;
      },
      #[structopt(name = "fetch")]
      Fetch {
          #[structopt(long = "dry-run")]
          dry_run: bool,
          #[structopt(long = "all")]
          all: bool,
          repository: Option&lt;String&gt;
      },
      #[structopt(name = "commit")]
      Commit {
          #[structopt(short = "m")]
          message: Option&lt;String&gt;,
          #[structopt(short = "a")]
          all: bool
      }
  }
  
  fn main() {
      let opt = Git::from_args();
      println!("{:?}", opt);
  
      match opt() {
          Git::Add(cmd) =&gt; println!("{:?}", cmd.interactive),
          _ =&gt; (),
      }
  }
  </code></pre>
  
  <p>Compilation:</p>
  
  <pre class="lang-none prettyprint-override"><code>05:42 $ cargo run -- add -i
     Compiling example v0.1.0 (file:///Users/froyer/src/example)
  error[E0532]: expected tuple struct/variant, found struct variant `Git::Add`
    --&gt; src/main.rs:41:9
     |
  41 |         Git::Add(cmd) =&gt; println!("{:?}", cmd.interactive),
     |         ^^^^^^^^ did you mean `Git::Add { /* fields */ }`?
  
  error[E0618]: expected function, found enum variant `opt`
    --&gt; src/main.rs:40:11
     |
  37 |     let opt = Git::from_args();
     |         --- `opt` defined here
  ...
  40 |     match opt() {
     |           ^^^^^ not a function
  help: `opt` is a unit variant, you need to write it without the parenthesis
     |
  40 |     match opt {
     |           ^^^
  </code></pre>