mirror of
https://github.com/clap-rs/clap
synced 2024-11-11 07:14:15 +00:00
docs(examples): Be consistent in define and read order
This threw me off because the arguments are so similar, I kept relying on the order but they were swapped.
This commit is contained in:
parent
cdc5026410
commit
6fc9c7cff4
1 changed files with 9 additions and 9 deletions
|
@ -26,15 +26,6 @@ fn main() {
|
|||
.arg("-l [len] 'A length to use, defaults to 10 when omitted'")
|
||||
.get_matches();
|
||||
|
||||
// Here we get a value of type u32 from our optional -l argument.
|
||||
// If the value provided to len fails to parse or not present, we default to 10
|
||||
//
|
||||
// Using other methods such as unwrap_or_else(|e| println!("{}",e))
|
||||
// are possible too.
|
||||
let len: u32 = matches.value_of_t("l").unwrap_or(10);
|
||||
|
||||
println!("len ({}) + 2 = {}", len, len + 2);
|
||||
|
||||
// This code loops through all the values provided to "seq" and adds 2
|
||||
// If seq fails to parse, the program exits, you don't have an option
|
||||
for v in matches
|
||||
|
@ -43,4 +34,13 @@ fn main() {
|
|||
{
|
||||
println!("Sequence part {} + 2: {}", v, v + 2);
|
||||
}
|
||||
|
||||
// Here we get a value of type u32 from our optional -l argument.
|
||||
// If the value provided to len fails to parse or not present, we default to 10
|
||||
//
|
||||
// Using other methods such as unwrap_or_else(|e| println!("{}",e))
|
||||
// are possible too.
|
||||
let len: u32 = matches.value_of_t("l").unwrap_or(10);
|
||||
|
||||
println!("len ({}) + 2 = {}", len, len + 2);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue