mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 22:02:35 +00:00
Added subcommand information
This commit is contained in:
parent
65a8a4f045
commit
e13399b60b
1 changed files with 19 additions and 2 deletions
21
README.md
21
README.md
|
@ -17,7 +17,7 @@ Command Line Argument Parser written in Rust
|
|||
|
||||
```rust
|
||||
extern crate clap;
|
||||
use clap::{Arg, App};
|
||||
use clap::{Arg, App, SubCommand};
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -37,6 +37,11 @@ Command Line Argument Parser written in Rust
|
|||
.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") {
|
||||
|
@ -54,6 +59,14 @@ Command Line Argument Parser written in Rust
|
|||
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...
|
||||
```
|
||||
|
||||
|
@ -66,7 +79,7 @@ Command Line Argument Parser written in Rust
|
|||
Does awesome things
|
||||
|
||||
USAGE:
|
||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL]
|
||||
MyApp [FLAGS] [OPTIONS] [POSITIONAL] [SUBCOMMANDS]
|
||||
|
||||
FLAGS:
|
||||
-d Turn debugging information on
|
||||
|
@ -78,6 +91,10 @@ Command Line Argument Parser written in Rust
|
|||
|
||||
POSITIONAL ARGUMENTS:
|
||||
output Sets an optional output file
|
||||
|
||||
SUBCOMMANDS:
|
||||
help Prints this message
|
||||
test Controls testing features
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
|
Loading…
Reference in a new issue