]>
git.proxmox.com Git - rustc.git/blob - vendor/structopt/examples/basic.rs
510e0e0fd353dfb5c400dcc4e44a1ab242fa9230
1 //! A somewhat comprehensive example of a typical `StructOpt` usage.use
3 use std
::path
::PathBuf
;
4 use structopt
::StructOpt
;
7 #[derive(StructOpt, Debug)]
8 #[structopt(name = "basic")]
10 // A flag, true if used in the command line. Note doc comment will
11 // be used for the help message of the flag. The name of the
12 // argument will be, by default, based on the name of the field.
13 /// Activate debug mode
14 #[structopt(short, long)]
17 // The number of occurrences of the `v/verbose` flag
18 /// Verbose mode (-v, -vv, -vvv, etc.)
19 #[structopt(short, long, parse(from_occurrences))]
23 #[structopt(short, long, default_value = "42")]
27 #[structopt(short, long, parse(from_os_str))]
30 // the long option will be translated by default to kebab case,
33 #[structopt(short = "c", long)]
36 /// admin_level to consider
37 #[structopt(short, long)]
41 #[structopt(name = "FILE", parse(from_os_str))]
46 let opt
= Opt
::from_args();
47 println
!("{:#?}", opt
);