mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
fix(clap_complete_fig): Correct requiresEquals
name and add it to the right objects
This commit is contained in:
parent
3034fdbbdd
commit
5689adc875
6 changed files with 15 additions and 13 deletions
|
@ -51,12 +51,13 @@ pub fn special_commands_command(name: &'static str) -> clap::Command<'static> {
|
|||
.long("--config")
|
||||
.hide(true)
|
||||
.takes_value(true)
|
||||
.require_equals(true)
|
||||
.help("the other case to test"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::new("path")
|
||||
.takes_value(true)
|
||||
.require_equals(true),
|
||||
.multiple_occurrences(true),
|
||||
),
|
||||
)
|
||||
.subcommand(clap::Command::new("some-cmd-with-hyphens").alias("hyphen"))
|
||||
|
|
|
@ -90,7 +90,7 @@ _my-app() {
|
|||
return 0
|
||||
;;
|
||||
my__app__some_cmd)
|
||||
opts="-h -V --config --help --version <path>"
|
||||
opts="-h -V --config --help --version <path>..."
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
|
|
|
@ -50,7 +50,7 @@ _arguments "${_arguments_options[@]}" /
|
|||
'--help[Print help information]' /
|
||||
'-V[Print version information]' /
|
||||
'--version[Print version information]' /
|
||||
'::path:' /
|
||||
'*::path:' /
|
||||
&& ret=0
|
||||
;;
|
||||
(some-cmd-with-hyphens)
|
||||
|
|
|
@ -96,14 +96,6 @@ fn gen_fig_inner(
|
|||
|
||||
let args = cmd.get_positionals().collect::<Vec<_>>();
|
||||
|
||||
if args.iter().any(|&x| x.is_require_equals_set()) {
|
||||
buffer.push_str(&format!(
|
||||
"{:indent$}requireEquals: true,\n",
|
||||
"",
|
||||
indent = indent
|
||||
));
|
||||
}
|
||||
|
||||
match args.len() {
|
||||
0 => {}
|
||||
1 => {
|
||||
|
@ -210,6 +202,14 @@ fn gen_options(cmd: &Command, indent: usize) -> String {
|
|||
));
|
||||
}
|
||||
|
||||
if option.is_require_equals_set() {
|
||||
buffer.push_str(&format!(
|
||||
"{:indent$}requiresEquals: true,\n",
|
||||
"",
|
||||
indent = indent + 4
|
||||
));
|
||||
}
|
||||
|
||||
buffer.push_str(&format!("{:indent$}args: ", "", indent = indent + 4));
|
||||
|
||||
buffer.push_str(&gen_args(option, indent + 4));
|
||||
|
|
|
@ -51,12 +51,13 @@ pub fn special_commands_command(name: &'static str) -> clap::Command<'static> {
|
|||
.long("--config")
|
||||
.hide(true)
|
||||
.takes_value(true)
|
||||
.require_equals(true)
|
||||
.help("the other case to test"),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::new("path")
|
||||
.takes_value(true)
|
||||
.require_equals(true),
|
||||
.multiple_occurrences(true),
|
||||
),
|
||||
)
|
||||
.subcommand(clap::Command::new("some-cmd-with-hyphens").alias("hyphen"))
|
||||
|
|
|
@ -32,6 +32,7 @@ const completion: Fig.Spec = {
|
|||
name: "--config",
|
||||
description: "the other case to test",
|
||||
hidden: true,
|
||||
requiresEquals: true,
|
||||
args: {
|
||||
name: "config",
|
||||
isOptional: true,
|
||||
|
@ -46,7 +47,6 @@ const completion: Fig.Spec = {
|
|||
description: "Print version information",
|
||||
},
|
||||
],
|
||||
requireEquals: true,
|
||||
args: {
|
||||
name: "path",
|
||||
isOptional: true,
|
||||
|
|
Loading…
Reference in a new issue