Created
March 5, 2019 01:10
-
-
Save AlecTaylor/694386102d21a5ff766a135e8f0674b4 to your computer and use it in GitHub Desktop.
structopt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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