nyra 0.1.1

Network Yield Runtime Assistant : system assistant for process control and monitoring.
mod cli;
mod process;

use crate::cli::{Cli, Commands};
use clap::Parser;

fn main() {
    let cli = Cli::parse();

    match cli.command {
        Some(Commands::Read { path }) => {
            println!("Reading file: {}", path);
            // To call file module
        }

        Some(Commands::Run { program }) => {
            println!("Launching program: {}", program);

            match process::run_program(&program) {
                Ok(status) => println!("Program exited with status: {:?}", status),
                Err(e) => eprintln!("Failed to run program: {}", e),
            }
        }
        Some(Commands::List) => {
            println!("Running processes:");

            let processes = process::list_processes();

            for (pid, cmd) in processes {
                println!("PID: {:<6} CMD: {}", pid, cmd);
            }
        }

        Some(Commands::Stop { pid }) => {
            println!("Stopping process: {pid}");

            match process::stop_process(pid) {
                Ok(_) => println!("Process {pid} stopped."),
                Err(err) => eprintln!("{err}"),
            }
        }

        Some(Commands::Describe { pid }) => {
            println!("{}", process::process_info(pid));
        }
        Some(Commands::Stats { pid }) => match process::process_stats(pid) {
            Ok(info) => println!("{info}"),
            Err(e) => println!("Error: {e}"),
        },

        None => println!("No command given. Use --help"),
    }
}