mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
tests(subcommand help): change to new usage generation known good
This commit is contained in:
parent
02462150ca
commit
e2488e50e4
3 changed files with 6 additions and 8 deletions
|
@ -90,7 +90,7 @@ Kevin K. <kbknapp@gmail.com>
|
|||
tests subcommands
|
||||
|
||||
USAGE:
|
||||
claptests subcmd [FLAGS] [OPTIONS] [POSITIONAL]
|
||||
claptests subcmd [FLAGS] [OPTIONS] [POSITIONAL]
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
|
|
10
src/app.rs
10
src/app.rs
|
@ -61,7 +61,6 @@ pub struct App<'a, 'v, 'ab, 'u, 'ar> {
|
|||
long_list: HashSet<&'ar str>,
|
||||
blacklist: HashSet<&'ar str>,
|
||||
usage_str: Option<&'u str>,
|
||||
usage: Option<String>,
|
||||
bin_name: Option<String>
|
||||
|
||||
}
|
||||
|
@ -98,7 +97,6 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
short_list: HashSet::new(),
|
||||
long_list: HashSet::new(),
|
||||
usage_str: None,
|
||||
usage: None,
|
||||
blacklist: HashSet::new(),
|
||||
bin_name: None,
|
||||
}
|
||||
|
@ -462,9 +460,9 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
if opts {
|
||||
write!(&mut usage," {}",
|
||||
if num_req_opts != self.opts.len() && !req_opts.is_empty() {
|
||||
format!("[OPTIONS] {}", &req_opts[..])
|
||||
format!(" [OPTIONS] {}", &req_opts[..])
|
||||
} else if req_opts.is_empty() {
|
||||
"[OPTIONS]".to_owned()
|
||||
" [OPTIONS]".to_owned()
|
||||
} else {
|
||||
req_opts
|
||||
});
|
||||
|
@ -472,9 +470,9 @@ impl<'a, 'v, 'ab, 'u, 'ar> App<'a, 'v, 'ab, 'u, 'ar>{
|
|||
if pos {
|
||||
write!(&mut usage, " {}",
|
||||
if num_req_pos != self.positionals_idx.len() && !req_pos.is_empty() {
|
||||
format!("[POSITIONAL] {}", &req_pos[..])
|
||||
format!(" [POSITIONAL] {}", &req_pos[..])
|
||||
} else if req_pos.is_empty() {
|
||||
"[POSITIONAL]".to_owned()
|
||||
" [POSITIONAL]".to_owned()
|
||||
} else {
|
||||
req_pos
|
||||
} );
|
||||
|
|
|
@ -274,7 +274,7 @@ impl<'a> ArgMatches<'a> {
|
|||
/// ```no_run
|
||||
/// # use clap::{App, Arg, SubCommand};
|
||||
/// # let app_matches = App::new("myapp").subcommand(SubCommand::new("test")).get_matches();
|
||||
/// println!(matches.usage());
|
||||
/// println!("{}",app_matches.usage().unwrap());
|
||||
/// ```
|
||||
pub fn usage(&self) -> Option<&str> {
|
||||
if let Some( ref u ) = self.usage {
|
||||
|
|
Loading…
Reference in a new issue