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

This commit is contained in:
Lucas Fernandes Nogueira 2022-05-29 06:06:57 -07:00 committed by GitHub
parent 2c040eaadd
commit f685df399a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

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

View File

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

View File

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