mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-03 16:42:42 +03:00
feat(tauri) CLI args additions (positional args, bool as value for args with takesValue=false) (#695)
This commit is contained in:
parent
1f2ff7dc25
commit
d299a2b94d
@ -19,7 +19,7 @@ export interface CliArg {
|
||||
requiresIf?: [string, string]
|
||||
requiredIf?: [string, string]
|
||||
requireEquals?: boolean
|
||||
global?: boolean
|
||||
index?: number
|
||||
}
|
||||
|
||||
export interface CliConfig {
|
||||
|
@ -76,7 +76,7 @@ fn map_matches<T: Cli + 'static>(config: &T, matches: &ArgMatches, cli_matches:
|
||||
for arg in args {
|
||||
let occurrences = matches.occurrences_of(arg.name.clone());
|
||||
let value = if occurrences == 0 || !arg.takes_value.unwrap_or(false) {
|
||||
Value::Null
|
||||
Value::Bool(occurrences > 0)
|
||||
} else if arg.multiple.unwrap_or(false) {
|
||||
matches
|
||||
.values_of(arg.name.clone())
|
||||
@ -142,6 +142,7 @@ fn get_app<'a, T: Cli + 'static>(name: &str, about: Option<&'a String>, config:
|
||||
clap_arg = bind_if_arg!(arg, clap_arg, requires_if);
|
||||
clap_arg = bind_if_arg!(arg, clap_arg, required_if);
|
||||
clap_arg = bind_value_arg!(arg, clap_arg, require_equals);
|
||||
clap_arg = bind_value_arg!(arg, clap_arg, index);
|
||||
|
||||
app = app.arg(clap_arg);
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ pub struct CliArg {
|
||||
pub requires_if: Option<Vec<String>>,
|
||||
pub required_if: Option<Vec<String>>,
|
||||
pub require_equals: Option<bool>,
|
||||
pub index: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Deserialize, Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user