Skip to content

Commit c1ec5f9

Browse files
committed
Improve the first example in the documentation
Fix #82
1 parent 73b6b67 commit c1ec5f9

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.2.5 (2018-XX-XX)
2+
3+
* Improve first example in the documentation ([#82](https://github.com/TeXitoi/structopt/issues/82)) by [@TeXitoi](https://github.com/TeXitoi)
4+
15
# v0.2.5 (2018-03-07)
26

37
* Work around breakage when `proc-macro2`'s nightly feature is enabled. ([#77](https://github.com/Texitoi/structopt/pull/77) and [proc-macro2#67](https://github.com/alexcrichton/proc-macro2/issues/67)) by [@fitzgen](https://github.com/fitzgen)

src/lib.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,34 @@
2525
//!
2626
//! First, let's look at an example:
2727
//!
28-
//! ```
29-
//! #[macro_use] extern crate structopt;
28+
//! ```should_panic
29+
//! #[macro_use]
30+
//! extern crate structopt;
31+
//!
3032
//! use std::path::PathBuf;
31-
//! #[derive(StructOpt)]
33+
//! use structopt::StructOpt;
34+
//!
35+
//! #[derive(Debug, StructOpt)]
3236
//! #[structopt(name = "example", about = "An example of StructOpt usage.")]
3337
//! struct Opt {
34-
//! #[structopt(short = "d", long = "debug", help = "Activate debug mode")]
38+
//! /// Activate debug mode
39+
//! #[structopt(short = "d", long = "debug")]
3540
//! 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")]
3743
//! speed: f64,
38-
//! #[structopt(help = "Input file", parse(from_os_str))]
44+
//! /// Input file
45+
//! #[structopt(parse(from_os_str))]
3946
//! 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))]
4149
//! output: Option<PathBuf>,
4250
//! }
43-
//! # fn main() {}
51+
//!
52+
//! fn main() {
53+
//! let opt = Opt::from_args();
54+
//! println!("{:?}", opt);
55+
//! }
4456
//! ```
4557
//!
4658
//! So `derive(StructOpt)` tells Rust to generate a command line parser,

0 commit comments

Comments
 (0)