Skip to content

Commit

Permalink
fix(cli): parsing of arguments with multiple values, closes #4231 (#4233
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lucasfernog committed May 29, 2022
1 parent 2c040ea commit f685df3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-cli-multiple-values.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---

Fixes multiple occurrences handling of the `bundles` and `features` arguments.
13 changes: 8 additions & 5 deletions tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit f685df3

Please sign in to comment.