From f685df399a5a05480b6e4f5d92da71f3b87895ef Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 29 May 2022 06:06:57 -0700 Subject: [PATCH] fix(cli): parsing of arguments with multiple values, closes #4231 (#4233) --- .changes/fix-cli-multiple-values.md | 6 ++++++ tooling/cli/src/build.rs | 13 ++++++++----- tooling/cli/src/dev.rs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .changes/fix-cli-multiple-values.md diff --git a/.changes/fix-cli-multiple-values.md b/.changes/fix-cli-multiple-values.md new file mode 100644 index 000000000..b7ee18b58 --- /dev/null +++ b/.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. diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index 7e88a892d..fa464b56c 100644 --- a/tooling/cli/src/build.rs +++ b/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, - /// 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>, - /// 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>, /// 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::>()) + { if name == "none" { break; } diff --git a/tooling/cli/src/dev.rs b/tooling/cli/src/dev.rs index 48e1b35f5..b579a8ed8 100644 --- a/tooling/cli/src/dev.rs +++ b/tooling/cli/src/dev.rs @@ -52,7 +52,7 @@ pub struct Options { #[clap(short, long)] target: Option, /// List of cargo features to activate - #[clap(short, long)] + #[clap(short, long, multiple_occurrences(true), multiple_values(true))] features: Option>, /// Exit on panic #[clap(short, long)]