mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Merge pull request #71 from kbknapp/from-usage
trim whitespace before parsing on App::args_from_usage()
This commit is contained in:
commit
36160fc47f
4 changed files with 8 additions and 9 deletions
|
@ -70,9 +70,9 @@ fn main() {
|
|||
.author("Kevin K. <kbknapp@gmail.com>")
|
||||
.about("Does awesome things")
|
||||
.args_from_usage(
|
||||
"-c --config=[CONFIG] 'Sets a custom config file'
|
||||
<INPUT> 'Sets the input file to use'
|
||||
[debug]... -d 'Sets the level of debugging information'")
|
||||
"-c --config=[CONFIG] 'Sets a custom config file'
|
||||
<INPUT> 'Sets the input file to use'
|
||||
[debug]... -d 'Sets the level of debugging information'")
|
||||
.subcommand(SubCommand::new("test")
|
||||
.about("controls testing features")
|
||||
.version("1.3")
|
||||
|
|
|
@ -3,10 +3,9 @@ extern crate clap;
|
|||
use clap::{App, Arg, SubCommand};
|
||||
|
||||
fn main() {
|
||||
let args =
|
||||
"-f --flag... 'tests flags'
|
||||
-o --option=[opt]... 'tests options'
|
||||
[positional] 'tests positionals'";
|
||||
let args = "-f --flag... 'tests flags'
|
||||
-o --option=[opt]... 'tests options'
|
||||
[positional] 'tests positionals'";
|
||||
// Test version from Cargo.toml
|
||||
let version = format!("{}.{}.{}{}",
|
||||
env!("CARGO_PKG_VERSION_MAJOR"),
|
||||
|
|
|
@ -396,7 +396,7 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
/// ```
|
||||
pub fn args_from_usage(mut self, usage: &'ar str) -> App<'a, 'v, 'ab, 'u, 'ar> {
|
||||
for l in usage.lines() {
|
||||
self = self.arg(Arg::from_usage(l));
|
||||
self = self.arg(Arg::from_usage(l.trim()));
|
||||
}
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue