Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Created March 5, 2019 01:10
Show Gist options
  • Save AlecTaylor/694386102d21a5ff766a135e8f0674b4 to your computer and use it in GitHub Desktop.
Save AlecTaylor/694386102d21a5ff766a135e8f0674b4 to your computer and use it in GitHub Desktop.
structopt
#[macro_use]
extern crate structopt;
use std::path::PathBuf;
use structopt::StructOpt;
// env!("CARGO_PKG_NAME")
#[derive(Debug, StructOpt)]
#[structopt(name = "example", about = "Something something dark side")]
enum Opt {
#[structopt(name = "info")]
Info {
#[structopt(long = "dry-run")]
dry_run: bool,
#[structopt(long = "all")]
all: bool,
repository: Option<String>,
},
#[structopt(name = "warn")]
Warn {
#[structopt(short = "a")]
all: bool,
},
}
fn main() {
let opt: Opt = Opt::from_args();
match opt.command {
Opt::Info => {
println!("Info")
}
_ => println!("{:?}", opt)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment