Skip to content

Commit 3242e1c

Browse files
authored
feat(cli): allow passing Cargo commands to mobile dev/build commands (#13659)
* feat(cli): allow passing Cargo commands to mobile dev/build commands * fmt
1 parent 4a880ca commit 3242e1c

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

.changes/mobile-args.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": "minor:feat"
3+
"@tauri-apps/cli": "minor:feat"
4+
---
5+
6+
Allow passing Cargo arguments to mobile dev and build commands.

crates/tauri-cli/src/mobile/android/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ pub struct Options {
7373
/// Skip prompting for values
7474
#[clap(long, env = "CI")]
7575
pub ci: bool,
76+
/// Command line arguments passed to the runner.
77+
/// Use `--` to explicitly mark the start of the arguments.
78+
/// e.g. `tauri android build -- [runnerArgs]`.
79+
#[clap(last(true))]
80+
pub args: Vec<String>,
7681
}
7782

7883
impl From<Options> for BuildOptions {
@@ -85,7 +90,7 @@ impl From<Options> for BuildOptions {
8590
bundles: None,
8691
no_bundle: false,
8792
config: options.config,
88-
args: Vec::new(),
93+
args: options.args,
8994
ci: options.ci,
9095
}
9196
}
@@ -197,6 +202,7 @@ fn run_build(
197202
let interface_options = InterfaceOptions {
198203
debug: build_options.debug,
199204
target: build_options.target.clone(),
205+
args: build_options.args.clone(),
200206
..Default::default()
201207
};
202208

crates/tauri-cli/src/mobile/android/dev.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ pub struct Options {
9696
/// Specify port for the built-in dev server for static files. Defaults to 1430.
9797
#[clap(long, env = "TAURI_CLI_PORT")]
9898
pub port: Option<u16>,
99+
/// Command line arguments passed to the runner.
100+
/// Use `--` to explicitly mark the start of the arguments.
101+
/// e.g. `tauri android dev -- [runnerArgs]`.
102+
#[clap(last(true))]
103+
pub args: Vec<String>,
99104
}
100105

101106
impl From<Options> for DevOptions {
@@ -106,7 +111,7 @@ impl From<Options> for DevOptions {
106111
features: options.features,
107112
exit_on_panic: options.exit_on_panic,
108113
config: options.config,
109-
args: Vec::new(),
114+
args: options.args,
110115
no_watch: options.no_watch,
111116
no_dev_server_wait: options.no_dev_server_wait,
112117
no_dev_server: options.no_dev_server,
@@ -257,7 +262,7 @@ fn run_dev(
257262
MobileOptions {
258263
debug: !options.release_mode,
259264
features: options.features,
260-
args: Vec::new(),
265+
args: options.args,
261266
config: dev_options.config.clone(),
262267
no_watch: options.no_watch,
263268
},

crates/tauri-cli/src/mobile/ios/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ pub struct Options {
8383
/// Use this to create a package ready for the App Store (app-store-connect option) or TestFlight (release-testing option).
8484
#[clap(long, value_enum)]
8585
pub export_method: Option<ExportMethod>,
86+
/// Command line arguments passed to the runner.
87+
/// Use `--` to explicitly mark the start of the arguments.
88+
/// e.g. `tauri ios build -- [runnerArgs]`.
89+
#[clap(last(true))]
90+
pub args: Vec<String>,
8691
}
8792

8893
#[derive(Debug, Clone, Copy, ValueEnum)]
@@ -125,7 +130,7 @@ impl From<Options> for BuildOptions {
125130
bundles: None,
126131
no_bundle: false,
127132
config: options.config,
128-
args: Vec::new(),
133+
args: options.args,
129134
ci: options.ci,
130135
}
131136
}
@@ -282,6 +287,7 @@ fn run_build(
282287
let out_dir = app_settings.out_dir(&InterfaceOptions {
283288
debug: build_options.debug,
284289
target: build_options.target.clone(),
290+
args: build_options.args.clone(),
285291
..Default::default()
286292
})?;
287293
let _lock = flock::open_rw(out_dir.join("lock").with_extension("ios"), "iOS")?;

crates/tauri-cli/src/mobile/ios/dev.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ pub struct Options {
101101
/// Specify port for the built-in dev server for static files. Defaults to 1430.
102102
#[clap(long, env = "TAURI_CLI_PORT")]
103103
pub port: Option<u16>,
104+
/// Command line arguments passed to the runner.
105+
/// Use `--` to explicitly mark the start of the arguments.
106+
/// e.g. `tauri ios dev -- [runnerArgs]`.
107+
#[clap(last(true))]
108+
pub args: Vec<String>,
104109
}
105110

106111
impl From<Options> for DevOptions {
@@ -112,7 +117,7 @@ impl From<Options> for DevOptions {
112117
exit_on_panic: options.exit_on_panic,
113118
config: options.config,
114119
release_mode: options.release_mode,
115-
args: Vec::new(),
120+
args: options.args,
116121
no_watch: options.no_watch,
117122
no_dev_server: options.no_dev_server,
118123
no_dev_server_wait: options.no_dev_server_wait,
@@ -265,7 +270,7 @@ fn run_dev(
265270
MobileOptions {
266271
debug: true,
267272
features: options.features,
268-
args: Vec::new(),
273+
args: options.args,
269274
config: dev_options.config.clone(),
270275
no_watch: options.no_watch,
271276
},

0 commit comments

Comments
 (0)