]> git.proxmox.com Git - rustc.git/blob - src/vendor/docopt/examples/verbose_multiple.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / vendor / docopt / examples / verbose_multiple.rs
1 extern crate rustc_serialize;
2 extern crate docopt;
3
4 use docopt::Docopt;
5
6 // This shows how to implement multiple levels of verbosity.
7 //
8 // When you have multiple patterns, I think the only way to carry the
9 // repeated flag through all of them is to specify it for each pattern
10 // explicitly.
11 //
12 // This is unfortunate.
13 const USAGE: &'static str = "
14 Usage: cp [options] [-v | -vv | -vvv] <source> <dest>
15 cp [options] [-v | -vv | -vvv] <source>... <dir>
16
17 Options:
18 -a, --archive Copy everything.
19 -v, --verbose Show extra log output.
20 ";
21
22 #[derive(Debug, RustcDecodable)]
23 struct Args {
24 arg_source: Vec<String>,
25 arg_dest: String,
26 arg_dir: String,
27 flag_archive: bool,
28 flag_verbose: usize,
29 }
30
31 fn main() {
32 let args: Args = Docopt::new(USAGE)
33 .and_then(|d| d.decode())
34 .unwrap_or_else(|e| e.exit());
35 println!("{:?}", args);
36 }