mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-19 04:08:45 +03:00
This commit is contained in:
parent
6d4945c9f0
commit
6218c31e17
5
.changes/retain-args.md
Normal file
5
.changes/retain-args.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch
|
||||
---
|
||||
|
||||
Retain command line arguments in `api::process::restart`.
|
@ -105,11 +105,14 @@ pub struct Env {
|
||||
/// The APPDIR environment variable.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub appdir: Option<std::ffi::OsString>,
|
||||
/// The command line arguments of the current process.
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)]
|
||||
impl Default for Env {
|
||||
fn default() -> Self {
|
||||
let args = std::env::args().skip(1).collect();
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let env = Self {
|
||||
@ -117,6 +120,7 @@ impl Default for Env {
|
||||
appimage: std::env::var_os("APPIMAGE"),
|
||||
#[cfg(target_os = "linux")]
|
||||
appdir: std::env::var_os("APPDIR"),
|
||||
args,
|
||||
};
|
||||
if env.appimage.is_some() || env.appdir.is_some() {
|
||||
// validate that we're actually running on an AppImage
|
||||
@ -139,7 +143,7 @@ impl Default for Env {
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
Self {}
|
||||
Self { args }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ pub fn restart(env: &Env) {
|
||||
|
||||
if let Ok(path) = current_binary(env) {
|
||||
Command::new(path)
|
||||
.args(&env.args)
|
||||
.spawn()
|
||||
.expect("application failed to start");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user