/* * SPDX-FileCopyrightText: 2025 April Faye John & Contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release mod bininfo; mod gui; mod pman; use bunt::println; use clap::{Parser, Subcommand}; use log::info; use pman::{init_process_manager, ProcessCommand, ProcessManager}; use shadow_rs::shadow; use std::sync::{Arc, Mutex, OnceLock}; use tokio::{signal, sync::mpsc::Sender}; shadow!(build); static PMAN_SENDER: OnceLock> = OnceLock::new(); /// Simple program to greet a person #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { /// Name of the person to greet //#[arg(short, long)] //name: String, /// Number of times to greet //#[arg(short, long, default_value_t = 1)] //count: u8, #[command(subcommand)] command: Commands, } #[derive(Debug, Subcommand)] enum Commands { #[command(arg_required_else_help = true, about = "todo replace this cmd")] Clone { /// The remote to clone remote: String, }, #[command(about = "List compile time backed info to audit binary")] Shadow { outfile: Option }, #[command(about = "Show test gui")] Gui, Devtest, } #[tokio::main] async fn main() { env_logger::init(); let args = Args::parse(); let _ = init_process_manager(); match args.command { Commands::Clone { remote } => {} Commands::Shadow { outfile } => { bininfo::print_info(); return; } Commands::Gui => { let res = gui::gui_main(); if let Err(e) = res { println!("{}", e); } return; } Commands::Devtest => { PMAN_SENDER.get().unwrap().send(ProcessCommand::SpawnShellCmd { cmd: "sleep 100 && echo hello meow".to_string(), }).await.expect("TODO: panic message"); tokio::select! { _ = signal::ctrl_c() => { info!("Ctrl-c received"); let sender = PMAN_SENDER.get().unwrap(); let _ = sender.send(ProcessCommand::Shutdown).await; } } } }; //handling anything here for gui wont work println!("exit"); }