Parcourir la source

fix(cli): parsing of arguments with multiple values, closes #4231 (#4233)

Lucas Fernandes Nogueira il y a 3 ans
Parent
commit
f685df399a
3 fichiers modifiés avec 15 ajouts et 6 suppressions
  1. 6 0
      .changes/fix-cli-multiple-values.md
  2. 8 5
      tooling/cli/src/build.rs
  3. 1 1
      tooling/cli/src/dev.rs

+ 6 - 0
.changes/fix-cli-multiple-values.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Fixes multiple occurrences handling of the `bundles` and `features` arguments.

+ 8 - 5
tooling/cli/src/build.rs

@@ -32,11 +32,11 @@ pub struct Options {
   /// Note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed.
   #[clap(short, long)]
   target: Option<String>,
-  /// List of cargo features to activate
-  #[clap(short, long)]
+  /// Space or comma separated list of features to activate
+  #[clap(short, long, multiple_occurrences(true), multiple_values(true))]
   features: Option<Vec<String>>,
-  /// List of bundles to package
-  #[clap(short, long)]
+  /// Space or comma separated list of bundles to package
+  #[clap(short, long, multiple_occurrences(true), multiple_values(true))]
   bundles: Option<Vec<String>>,
   /// JSON string or path to JSON file to merge with tauri.conf.json
   #[clap(short, long)]
@@ -242,7 +242,10 @@ pub fn command(options: Options) -> Result<()> {
   if config_.tauri.bundle.active {
     let package_types = if let Some(names) = options.bundles {
       let mut types = vec![];
-      for name in names {
+      for name in names
+        .into_iter()
+        .flat_map(|n| n.split(',').map(|s| s.to_string()).collect::<Vec<String>>())
+      {
         if name == "none" {
           break;
         }

+ 1 - 1
tooling/cli/src/dev.rs

@@ -52,7 +52,7 @@ pub struct Options {
   #[clap(short, long)]
   target: Option<String>,
   /// List of cargo features to activate
-  #[clap(short, long)]
+  #[clap(short, long, multiple_occurrences(true), multiple_values(true))]
   features: Option<Vec<String>>,
   /// Exit on panic
   #[clap(short, long)]