Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use structopt::StructOpt;
- #[derive(Debug, StructOpt)]
- pub enum Command {
- #[structopt(name = "foo")]
- Foo {
- #[structopt(short = "i", long = "init")]
- init: bool,
- #[structopt(short = "r", long = "remove")]
- remove: bool,
- },
- #[structopt(name = "bar")]
- Bar {},
- #[structopt(name = "baz")]
- Baz {},
- }
- #[derive(Debug, StructOpt)]
- #[structopt()]
- pub struct Opts {
- /// Prints debug information
- #[structopt(short = "d", long = "debug")]
- pub debug: bool,
- /// Specify configuration file
- #[structopt(short = "c", long = "config")]
- pub config: Option<String>,
- #[structopt(subcommand)]
- pub cmd: Command,
- }
- fn main() {
- let cmd = cli::Command::from_args();
- match cmd.cmd {
- Foo { init, .. } => {
- do stuff with init
- },
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement