From 80bf7ba82dc428b93f9628ecc61976624c5258fe Mon Sep 17 00:00:00 2001 From: April John Date: Thu, 20 Feb 2025 14:04:16 +0100 Subject: [PATCH] feat: add experimental process manager --- .vscode/settings.json | 3 ++- src/main.rs | 18 +++++++++++++----- src/pman.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/pman.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index a717232..e9cd0c1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,6 @@ "images", "config", ".direnv" - ] + ], + "nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f1b0261..4dab361 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,8 +7,10 @@ mod gui; mod bininfo; +mod pman; use clap::{Subcommand, Parser}; +use pman::init_process_manager; use shadow_rs::shadow; shadow!(build); @@ -40,12 +42,16 @@ enum Commands { Shadow { outfile: Option, }, + #[command(about = "Show test gui")] + Gui, } fn main() { let args = Args::parse(); + init_process_manager(); + match args.command { 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); - } + }; } diff --git a/src/pman.rs b/src/pman.rs new file mode 100644 index 0000000..fdd374f --- /dev/null +++ b/src/pman.rs @@ -0,0 +1,43 @@ +/* + * SPDX-FileCopyrightText: 2025 April Faye John & 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 +} + +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) { + + } +} \ No newline at end of file