Added workspace restart command

This commit is contained in:
Mikayla Maki
2023-02-16 13:28:56 -08:00
parent ac882c7db5
commit cf83ecccbb
6 changed files with 58 additions and 10 deletions
+1
View File
@@ -18,6 +18,7 @@ clap = { version = "3.1", features = ["derive"] }
dirs = "3.0"
ipc-channel = "0.16"
serde = { version = "1.0", features = ["derive", "rc"] }
sysinfo = "0.27"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.9"
+12 -1
View File
@@ -14,8 +14,10 @@ use std::{
fs::{self, OpenOptions},
io,
path::{Path, PathBuf},
ptr,
ptr, thread,
time::Duration,
};
use sysinfo::{Pid, System, SystemExt};
#[derive(Parser)]
#[clap(name = "zed", global_setting(clap::AppSettings::NoAutoVersion))]
@@ -32,6 +34,8 @@ struct Args {
/// Custom Zed.app path
#[clap(short, long)]
bundle_path: Option<PathBuf>,
#[clap(short, long)]
restart_from: Option<Pid>,
}
#[derive(Debug, Deserialize)]
@@ -60,6 +64,13 @@ fn main() -> Result<()> {
return Ok(());
}
if let Some(parent_pid) = args.restart_from {
let mut system = System::new();
while system.refresh_process(parent_pid) {
thread::sleep(Duration::from_millis(100));
}
}
for path in args.paths.iter() {
if !path.exists() {
touch(path.as_path())?;