fix(core): CLI API usage of positional arguments, closes #2821 (#2823)

This commit is contained in:
Lucas Fernandes Nogueira
2021-10-29 09:22:10 -03:00
committed by GitHub
parent 2538bc639f
commit ed497d74c8
2 changed files with 10 additions and 5 deletions

View File

@@ -178,10 +178,13 @@ fn get_app<'a>(name: &str, about: Option<&'a String>, config: &'a CliConfig) ->
}
fn get_arg<'a>(arg_name: &'a str, arg: &'a CliArg) -> Arg<'a> {
let mut clap_arg = Arg::new(arg_name).long(arg_name);
let mut clap_arg = Arg::new(arg_name);
if let Some(short) = arg.short {
clap_arg = clap_arg.short(short);
if arg.index.is_none() {
clap_arg = clap_arg.long(arg_name);
if let Some(short) = arg.short {
clap_arg = clap_arg.short(short);
}
}
clap_arg = bind_string_arg!(arg, clap_arg, description, about);

View File

@@ -48,11 +48,13 @@ A positional argument is identified by its position in the list of arguments. Wi
"args": [
{
"name": "source",
"index": 1
"index": 1,
"takesValue": true
},
{
"name": "destination",
"index": 2
"index": 2,
"takesValue": true
}
]
}