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:
Ed Page 2022-08-30 16:01:22 -05:00
parent a00cbab1dc
commit c22b78ba61
3 changed files with 4 additions and 16 deletions

View file

@ -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

View file

@ -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

View file

@ -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