mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
Improve formatting for README, remove some tabs
This commit is contained in:
parent
9f4cdc9fa3
commit
59bcd85662
2 changed files with 69 additions and 69 deletions
110
README.md
110
README.md
|
@ -19,53 +19,53 @@ extern crate clap;
|
|||
use clap::{Arg, App, SubCommand};
|
||||
|
||||
fn main() {
|
||||
let matches = App::new("MyApp")
|
||||
.version("1.0")
|
||||
.author("Kevin K. <kbknapp@gmail.com>")
|
||||
.about("Does awesome things")
|
||||
.arg(Arg::new("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.help("Sets a custom config file")
|
||||
.takes_value(true))
|
||||
.arg(Arg::new("output")
|
||||
.help("Sets an optional output file")
|
||||
.index(1))
|
||||
.arg(Arg::new("debug")
|
||||
.short("d")
|
||||
.multiple(true)
|
||||
.help("Turn debugging information on"))
|
||||
.subcommand(SubCommand::new("test")
|
||||
.about("controls testing features")
|
||||
.arg(Arg::new("verbose")
|
||||
.short("v")
|
||||
.help("print test information verbosely")))
|
||||
.get_matches();
|
||||
|
||||
if let Some(o) = matches.value_of("output") {
|
||||
println!("Value for output: {}", o);
|
||||
}
|
||||
|
||||
if let Some(c) = matches.value_of("config") {
|
||||
println!("Value for config: {}", c);
|
||||
}
|
||||
|
||||
match matches.occurrences_of("debug") {
|
||||
0 => println!("Debug mode is off"),
|
||||
1 => println!("Debug mode is kind of on"),
|
||||
2 => println!("Debug mode is on"),
|
||||
3 | _ => println!("Don't be crazy"),
|
||||
}
|
||||
|
||||
if let Some(ref matches) = matches.subcommand_matches("test") {
|
||||
if matches.is_present("list") {
|
||||
println!("Printing testing lists...");
|
||||
} else {
|
||||
println!("Not printing testing lists...");
|
||||
}
|
||||
}
|
||||
|
||||
// more porgram logic goes here...
|
||||
let matches = App::new("MyApp")
|
||||
.version("1.0")
|
||||
.author("Kevin K. <kbknapp@gmail.com>")
|
||||
.about("Does awesome things")
|
||||
.arg(Arg::new("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.help("Sets a custom config file")
|
||||
.takes_value(true))
|
||||
.arg(Arg::new("output")
|
||||
.help("Sets an optional output file")
|
||||
.index(1))
|
||||
.arg(Arg::new("debug")
|
||||
.short("d")
|
||||
.multiple(true)
|
||||
.help("Turn debugging information on"))
|
||||
.subcommand(SubCommand::new("test")
|
||||
.about("controls testing features")
|
||||
.arg(Arg::new("verbose")
|
||||
.short("v")
|
||||
.help("print test information verbosely")))
|
||||
.get_matches();
|
||||
|
||||
if let Some(o) = matches.value_of("output") {
|
||||
println!("Value for output: {}", o);
|
||||
}
|
||||
|
||||
if let Some(c) = matches.value_of("config") {
|
||||
println!("Value for config: {}", c);
|
||||
}
|
||||
|
||||
match matches.occurrences_of("debug") {
|
||||
0 => println!("Debug mode is off"),
|
||||
1 => println!("Debug mode is kind of on"),
|
||||
2 => println!("Debug mode is on"),
|
||||
3 | _ => println!("Don't be crazy"),
|
||||
}
|
||||
|
||||
if let Some(ref matches) = matches.subcommand_matches("test") {
|
||||
if matches.is_present("list") {
|
||||
println!("Printing testing lists...");
|
||||
} else {
|
||||
println!("Not printing testing lists...");
|
||||
}
|
||||
}
|
||||
|
||||
// more porgram logic goes here...
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -78,22 +78,22 @@ Kevin K. <kbknapp@gmail.com>
|
|||
Does awesome things
|
||||
|
||||
USAGE:
|
||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
||||
|
||||
FLAGS:
|
||||
-d Turn debugging information on
|
||||
-h,--help Prints this message
|
||||
-v,--version Prints version information
|
||||
-d Turn debugging information on
|
||||
-h,--help Prints this message
|
||||
-v,--version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
-c,--config <config> Sets a custom config file
|
||||
-c,--config <config> Sets a custom config file
|
||||
|
||||
POSITIONAL ARGUMENTS:
|
||||
output Sets an optional output file
|
||||
output Sets an optional output file
|
||||
|
||||
SUBCOMMANDS:
|
||||
help Prints this message
|
||||
test Controls testing features
|
||||
help Prints this message
|
||||
test Controls testing features
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
|
28
src/lib.rs
28
src/lib.rs
|
@ -26,22 +26,22 @@
|
|||
//! .author("Kevin K. <kbknapp@gmail.com>")
|
||||
//! .about("Does awesome things")
|
||||
//! .arg(Arg::new("config")
|
||||
//! .short("c")
|
||||
//! .long("config")
|
||||
//! .help("Sets a custom config file")
|
||||
//! .takes_value(true))
|
||||
//! .short("c")
|
||||
//! .long("config")
|
||||
//! .help("Sets a custom config file")
|
||||
//! .takes_value(true))
|
||||
//! .arg(Arg::new("output")
|
||||
//! .help("Sets an optional output file")
|
||||
//! .index(1))
|
||||
//! .help("Sets an optional output file")
|
||||
//! .index(1))
|
||||
//! .arg(Arg::new("debug")
|
||||
//! .short("d")
|
||||
//! .multiple(true)
|
||||
//! .help("Turn debugging information on"))
|
||||
//! .short("d")
|
||||
//! .multiple(true)
|
||||
//! .help("Turn debugging information on"))
|
||||
//! .subcommand(SubCommand::new("test")
|
||||
//! .about("Has test sub functionality")
|
||||
//! .arg(Arg::new("verbose")
|
||||
//! .short("v")
|
||||
//! .help("Display verbose information")))
|
||||
//! .about("Has test sub functionality")
|
||||
//! .arg(Arg::new("verbose")
|
||||
//! .short("v")
|
||||
//! .help("Display verbose information")))
|
||||
//! .get_matches();
|
||||
//!
|
||||
//! if let Some(o) = matches.value_of("output") {
|
||||
|
@ -58,7 +58,7 @@
|
|||
//! 2 => println!("Debug mode is on"),
|
||||
//! 3 | _ => println!("Don't be crazy"),
|
||||
//! }
|
||||
//!
|
||||
//!
|
||||
//! if let Some(ref matches) = matches.subcommand_matches("test") {
|
||||
//! if matches.is_present("verbose") {
|
||||
//! println!("Printing verbose test info...");
|
||||
|
|
Loading…
Reference in a new issue