feat(cli.rs): add release argument to the dev command (#2192)

This commit is contained in:
Friedel Ziegelmayer
2021-07-12 17:59:02 +02:00
committed by GitHub
parent a410958d45
commit 7ee2dc8b69
4 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"cli.rs": patch
---
Adds `release` argument to the `dev` command. Allowing to run the backend in release mode during development.

View File

@@ -38,6 +38,9 @@ subcommands:
about: Args passed to the binary
index: 1
multiple: true
- release:
long: release
about: Run the code in release mode
- build:
about: Tauri build.
args:

View File

@@ -53,6 +53,7 @@ pub struct Dev {
exit_on_panic: bool,
config: Option<String>,
args: Vec<String>,
release_mode: bool,
}
impl Dev {
@@ -90,6 +91,11 @@ impl Dev {
self
}
pub fn release_mode(mut self, release_mode: bool) -> Self {
self.release_mode = release_mode;
self
}
pub fn run(self) -> crate::Result<()> {
let logger = Logger::new("tauri:dev");
let tauri_path = tauri_dir();
@@ -249,6 +255,10 @@ impl Dev {
let mut command = Command::new(runner);
command.args(&["run", "--no-default-features"]);
if self.release_mode {
command.args(&["--release"]);
}
if let Some(target) = &self.target {
command.args(&["--target", target]);
}

View File

@@ -147,11 +147,13 @@ fn dev_command(matches: &ArgMatches) -> Result<()> {
.values_of("args")
.map(|a| a.into_iter().map(|v| v.to_string()).collect())
.unwrap_or_default();
let release_mode = matches.is_present("release");
let mut dev_runner = dev::Dev::new()
.exit_on_panic(exit_on_panic)
.args(args)
.features(features);
.features(features)
.release_mode(release_mode);
if let Some(runner) = runner {
dev_runner = dev_runner.runner(runner.to_string());