mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
Fixed doc tests
This commit is contained in:
parent
b7fdf9024a
commit
152aa8919a
3 changed files with 32 additions and 33 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1,4 +1,4 @@
|
|||
[root]
|
||||
name = "clap"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use subcommand::SubCommand;
|
|||
///
|
||||
/// ```no_run
|
||||
/// # use clap::{App, Arg};
|
||||
/// let matches = App::new("MyApp")
|
||||
/// let matches = App::new("MyApp")
|
||||
/// // adding of arguments and configuration goes here...
|
||||
/// # .arg(Arg::new("config")
|
||||
/// # .long("config")
|
||||
|
@ -24,38 +24,37 @@ use subcommand::SubCommand;
|
|||
/// # .short("d")
|
||||
/// # .multiple(true))
|
||||
/// .get_matches();
|
||||
/// // if you had an argument named "output" that takes a value
|
||||
/// if let Some(o) = matches.value_of("output") {
|
||||
/// println!("Value for output: {}", o);
|
||||
/// }
|
||||
/// // if you had an argument named "output" that takes a value
|
||||
/// if let Some(o) = matches.value_of("output") {
|
||||
/// println!("Value for output: {}", o);
|
||||
/// }
|
||||
///
|
||||
/// // Although not advised, if you have a required argument
|
||||
/// // you can call .unwrap() because the program will exit long before
|
||||
/// // here at noticing the user didn't supply a required argument...
|
||||
/// // use at your own risk ;)
|
||||
/// println!("Config file: {}", matches.value_of("config").unwrap());
|
||||
/// // Although not advised, if you have a required argument
|
||||
/// // you can call .unwrap() because the program will exit long before
|
||||
/// // here at noticing the user didn't supply a required argument...
|
||||
/// // use at your own risk ;)
|
||||
/// println!("Config file: {}", matches.value_of("config").unwrap());
|
||||
///
|
||||
/// // You can check the present of an argument
|
||||
/// if matches.is_present("debug") {
|
||||
/// // Checking if "debug" was present was necessary,
|
||||
/// // as occurrences returns 0 if a flag isn't found
|
||||
/// // but we can check how many times "debug" was found
|
||||
/// // if we allow multiple (if multiple isn't allowed it always be 1 or 0)
|
||||
/// if matches.occurrences_of("debug") > 1 {
|
||||
/// println!("Debug mode is REALLY on");
|
||||
/// } else {
|
||||
/// println!("Debug mode kind of on");
|
||||
/// }
|
||||
/// }
|
||||
/// // You can check the present of an argument
|
||||
/// if matches.is_present("debug") {
|
||||
/// // Checking if "debug" was present was necessary,
|
||||
/// // as occurrences returns 0 if a flag isn't found
|
||||
/// // but we can check how many times "debug" was found
|
||||
/// // if we allow multiple (if multiple isn't allowed it always be 1 or 0)
|
||||
/// if matches.occurrences_of("debug") > 1 {
|
||||
/// println!("Debug mode is REALLY on");
|
||||
/// } else {
|
||||
/// println!("Debug mode kind of on");
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // You can get the sub-matches of a particular subcommand (in this case "test")
|
||||
/// // If "test" had it's own "-l" flag you could check for it's presence accordingly
|
||||
/// if let Some(ref matches) = matches.subcommand_matches("test") {
|
||||
/// if matches.is_present("list") {
|
||||
/// println!("Printing testing lists...");
|
||||
/// } else {
|
||||
/// println!("Not printing testing lists...");
|
||||
/// }
|
||||
/// // You can get the sub-matches of a particular subcommand (in this case "test")
|
||||
/// // If "test" had it's own "-l" flag you could check for it's presence accordingly
|
||||
/// if let Some(ref matches) = matches.subcommand_matches("test") {
|
||||
/// if matches.is_present("list") {
|
||||
/// println!("Printing testing lists...");
|
||||
/// } else {
|
||||
/// println!("Not printing testing lists...");
|
||||
/// }
|
||||
/// }
|
||||
pub struct ArgMatches {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
//! Example:
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use clap::{Arg, App};
|
||||
//! use clap::{Arg, App, SubCommand};
|
||||
//!
|
||||
//! // ...
|
||||
//!
|
||||
|
@ -37,7 +37,7 @@
|
|||
//! .short("d")
|
||||
//! .multiple(true)
|
||||
//! .help("Turn debugging information on"))
|
||||
//! .subcomamnd(SubCommand::new("test")
|
||||
//! .subcommand(SubCommand::new("test")
|
||||
//! .about("Has test sub functionality")
|
||||
//! .arg(Arg::new("verbose")
|
||||
//! .short("v")
|
||||
|
|
Loading…
Reference in a new issue