mirror of
https://github.com/clap-rs/clap
synced 2024-12-12 13:52:34 +00:00
fix(usage): Don't put in [--]
for multiple values
This was added in #165 but the relative value of this doesn't seem worth the complexity at the moment.
This commit is contained in:
parent
a00cbab1dc
commit
c22b78ba61
3 changed files with 4 additions and 16 deletions
|
@ -56,7 +56,7 @@ pacman-sync
|
|||
Synchronize packages.
|
||||
|
||||
Usage:
|
||||
pacman[EXE] {sync|--sync|-S} [OPTIONS] [--] [package]...
|
||||
pacman[EXE] {sync|--sync|-S} [OPTIONS] [package]...
|
||||
|
||||
Arguments:
|
||||
[package]... packages
|
||||
|
|
|
@ -70,19 +70,6 @@ impl<'cmd> Usage<'cmd> {
|
|||
self.write_required_usage_from(&[], None, false, &mut styled);
|
||||
}
|
||||
|
||||
let has_last = self.cmd.get_positionals().any(|p| p.is_last_set());
|
||||
// places a '--' in the usage string if there are args and options
|
||||
// supporting multiple values
|
||||
if self
|
||||
.cmd
|
||||
.get_non_positionals()
|
||||
.any(|o| o.is_multiple_values_set())
|
||||
&& self.cmd.get_positionals().any(|p| !p.is_required_set())
|
||||
&& !(self.cmd.has_visible_subcommands() || self.cmd.is_allow_external_subcommands_set())
|
||||
&& !has_last
|
||||
{
|
||||
styled.placeholder(" [--]");
|
||||
}
|
||||
let not_req_or_hidden =
|
||||
|p: &Arg| (!p.is_required_set() || p.is_last_set()) && !p.is_hide_set();
|
||||
if self.cmd.get_positionals().any(not_req_or_hidden) {
|
||||
|
@ -91,6 +78,7 @@ impl<'cmd> Usage<'cmd> {
|
|||
} else {
|
||||
styled.placeholder(" [ARGS]");
|
||||
}
|
||||
let has_last = self.cmd.get_positionals().any(|p| p.is_last_set());
|
||||
if has_last && incl_reqs {
|
||||
let pos = self
|
||||
.cmd
|
||||
|
|
|
@ -538,7 +538,7 @@ Kevin K. <kbknapp@gmail.com>
|
|||
tests subcommands
|
||||
|
||||
Usage:
|
||||
clap-test subcmd [OPTIONS] [--] [scpositional]
|
||||
clap-test subcmd [OPTIONS] [scpositional]
|
||||
|
||||
Arguments:
|
||||
[scpositional] tests positionals
|
||||
|
@ -954,7 +954,7 @@ foo
|
|||
bar
|
||||
|
||||
Usage:
|
||||
myapp [OPTIONS] [--] [ARGS]
|
||||
myapp [OPTIONS] [ARGS]
|
||||
|
||||
Arguments:
|
||||
[arg1] some option
|
||||
|
|
Loading…
Reference in a new issue