Pārlūkot izejas kodu

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

Friedel Ziegelmayer 4 gadi atpakaļ
vecāks
revīzija
7ee2dc8b69

+ 5 - 0
.changes/cli.rs-release-arg.md

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

+ 3 - 0
tooling/cli.rs/src/cli.yml

@@ -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:

+ 10 - 0
tooling/cli.rs/src/dev.rs

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

+ 3 - 1
tooling/cli.rs/src/main.rs

@@ -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());