Browse Source

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

Lucas Fernandes Nogueira 3 years ago
parent
commit
ed497d74c8
2 changed files with 10 additions and 5 deletions
  1. 6 3
      core/tauri/src/api/cli.rs
  2. 4 2
      docs/usage/guides/cli.md

+ 6 - 3
core/tauri/src/api/cli.rs

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

+ 4 - 2
docs/usage/guides/cli.md

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