feat: add experimental process manager

This commit is contained in:
April John 2025-02-20 14:04:16 +01:00
parent 97ef8cbe8a
commit 80bf7ba82d
3 changed files with 58 additions and 6 deletions

View file

@ -5,5 +5,6 @@
"images", "images",
"config", "config",
".direnv" ".direnv"
] ],
"nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix"
} }

View file

@ -7,8 +7,10 @@
mod gui; mod gui;
mod bininfo; mod bininfo;
mod pman;
use clap::{Subcommand, Parser}; use clap::{Subcommand, Parser};
use pman::init_process_manager;
use shadow_rs::shadow; use shadow_rs::shadow;
shadow!(build); shadow!(build);
@ -40,12 +42,16 @@ enum Commands {
Shadow { Shadow {
outfile: Option<String>, outfile: Option<String>,
}, },
#[command(about = "Show test gui")]
Gui,
} }
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
init_process_manager();
match args.command { match args.command {
Commands::Clone { remote } => { Commands::Clone { remote } => {
@ -59,10 +65,12 @@ fn main() {
} }
}; Commands::Gui => {
let res = gui::gui_main();
if let Err(e) = res {
println!("{}", e);
}
}
let res = gui::gui_main(); };
if let Err(e) = res {
println!("{}", e);
}
} }

43
src/pman.rs Normal file
View file

@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2025 April Faye John <april.john@denic.de> & Contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use clap::Command;
pub fn init_process_manager() {
let ProcessManager = ProcessManager::default();
}
pub struct ProcessManager {
processes: Vec<Command>
}
impl Default for ProcessManager {
fn default() -> ProcessManager {
ProcessManager {
processes: Vec::new(),
}
}
}
impl ProcessManager {
fn spawn_shell_command(self, command: String) {
if cfg!(target_os = "windows") {
return self.spawn_cmd_command(command);
} else if cfg!(target_os = "macos") {
return self.spawn_zsh_command(command);
} else {
return self.spawn_bash_command(command);
}
}
fn spawn_bash_command(self, command: String) {
}
fn spawn_cmd_command(self, command: String) {
}
fn spawn_zsh_command(self, command: String) {
}
}