|
25 | 25 | //!
|
26 | 26 | //! First, let's look at an example:
|
27 | 27 | //!
|
28 |
| -//! ``` |
29 |
| -//! #[macro_use] extern crate structopt; |
| 28 | +//! ```should_panic |
| 29 | +//! #[macro_use] |
| 30 | +//! extern crate structopt; |
| 31 | +//! |
30 | 32 | //! use std::path::PathBuf;
|
31 |
| -//! #[derive(StructOpt)] |
| 33 | +//! use structopt::StructOpt; |
| 34 | +//! |
| 35 | +//! #[derive(Debug, StructOpt)] |
32 | 36 | //! #[structopt(name = "example", about = "An example of StructOpt usage.")]
|
33 | 37 | //! struct Opt {
|
34 |
| -//! #[structopt(short = "d", long = "debug", help = "Activate debug mode")] |
| 38 | +//! /// Activate debug mode |
| 39 | +//! #[structopt(short = "d", long = "debug")] |
35 | 40 | //! debug: bool,
|
36 |
| -//! #[structopt(short = "s", long = "speed", help = "Set speed", default_value = "42")] |
| 41 | +//! /// Set speed |
| 42 | +//! #[structopt(short = "s", long = "speed", default_value = "42")] |
37 | 43 | //! speed: f64,
|
38 |
| -//! #[structopt(help = "Input file", parse(from_os_str))] |
| 44 | +//! /// Input file |
| 45 | +//! #[structopt(parse(from_os_str))] |
39 | 46 | //! input: PathBuf,
|
40 |
| -//! #[structopt(help = "Output file, stdout if not present", parse(from_os_str))] |
| 47 | +//! /// Output file, stdout if not present |
| 48 | +//! #[structopt(parse(from_os_str))] |
41 | 49 | //! output: Option<PathBuf>,
|
42 | 50 | //! }
|
43 |
| -//! # fn main() {} |
| 51 | +//! |
| 52 | +//! fn main() { |
| 53 | +//! let opt = Opt::from_args(); |
| 54 | +//! println!("{:?}", opt); |
| 55 | +//! } |
44 | 56 | //! ```
|
45 | 57 | //!
|
46 | 58 | //! So `derive(StructOpt)` tells Rust to generate a command line parser,
|
|
0 commit comments