]> git.proxmox.com Git - rustc.git/blob - src/vendor/docopt/examples/cargo.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / vendor / docopt / examples / cargo.rs
1 extern crate rustc_serialize;
2 extern crate docopt;
3
4 use docopt::Docopt;
5
6 // Write the Docopt usage string.
7 const USAGE: &'static str = "
8 Rust's package manager
9
10 Usage:
11 cargo <command> [<args>...]
12 cargo [options]
13
14 Options:
15 -h, --help Display this message
16 -V, --version Print version info and exit
17 --list List installed commands
18 -v, --verbose Use verbose output
19
20 Some common cargo commands are:
21 build Compile the current project
22 clean Remove the target directory
23 doc Build this project's and its dependencies' documentation
24 new Create a new cargo project
25 run Build and execute src/main.rs
26 test Run the tests
27 bench Run the benchmarks
28 update Update dependencies listed in Cargo.lock
29
30 See 'cargo help <command>' for more information on a specific command.
31 ";
32
33 #[derive(Debug, RustcDecodable)]
34 struct Args {
35 arg_command: Option<Command>,
36 arg_args: Vec<String>,
37 flag_list: bool,
38 flag_verbose: bool,
39 }
40
41 #[derive(Debug, RustcDecodable)]
42 enum Command {
43 Build, Clean, Doc, New, Run, Test, Bench, Update,
44 }
45
46 fn main() {
47 let args: Args = Docopt::new(USAGE)
48 .and_then(|d| d.options_first(true).decode())
49 .unwrap_or_else(|e| e.exit());
50 println!("{:?}", args);
51 }