clap/examples/basic.rs

36 lines
1 KiB
Rust
Raw Normal View History

2017-02-03 00:03:51 +00:00
// Copyright (c) 2017 Guillaume Pinot <texitoi(a)texitoi.eu>
//
// This work is free. You can redistribute it and/or modify it under
// the terms of the Do What The Fuck You Want To Public License,
// Version 2, as published by Sam Hocevar. See the COPYING file for
// more details.
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
#[macro_use]
extern crate clap;
use structopt::StructOpt;
2017-02-04 00:43:44 +00:00
#[derive(StructOpt, Debug)]
2017-02-03 00:03:51 +00:00
struct Opt {
2017-02-05 01:06:39 +00:00
#[structopt(short = "d", long = "debug", help = "Activate debug mode")]
2017-02-04 00:43:44 +00:00
debug: bool,
2017-02-05 01:06:39 +00:00
#[structopt(short = "v", long = "verbose", help = "Verbose mode")]
2017-02-04 00:43:44 +00:00
verbose: u64,
2017-02-05 01:06:39 +00:00
#[structopt(short = "s", long = "speed", help = "Set speed")]
2017-02-04 00:43:44 +00:00
speed: Option<f64>,
2017-02-05 01:06:39 +00:00
#[structopt(short = "o", long = "output", help = "Output file")]
2017-02-04 00:43:44 +00:00
output: String,
2017-02-05 01:06:39 +00:00
#[structopt(short = "l",
long = "level",
help = "admin_level to consider")]
2017-02-04 00:43:44 +00:00
level: Vec<String>,
2017-02-03 00:03:51 +00:00
}
fn main() {
let opt = Opt::from_args();
2017-02-04 00:43:44 +00:00
println!("{:?}", opt);
2017-02-03 00:03:51 +00:00
}