clap/examples/basic.rs

36 lines
1.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;
use structopt::StructOpt;
2017-02-04 00:43:44 +00:00
#[derive(StructOpt, Debug)]
2017-02-06 00:00:27 +00:00
#[structopt(name = "basic", about = "A basic example")]
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-06 22:55:46 +00:00
#[structopt(short = "s", long = "speed", help = "Set speed", default_value = "42")]
speed: 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-06 22:55:46 +00:00
#[structopt(short = "c", long = "car", help = "Number of car")]
car: Option<i32>,
#[structopt(short = "l", long = "level")]
#[structopt(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
}