From bc31ce6506713c1919d411e64cbdcd8809eae214 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Mar 2026 00:01:36 +0545 Subject: [PATCH] feat(src): add cooling and thermal management commands Adds a new Cooling command group with selectable fan profiles (Performance, Balanced, Quiet) and updates the CLI and logging accordingly. - New Features - Introduce Cooling subcommands for setting thermal management modes - Implement runtime logic to apply selected fan profiles - Enhancements - Extend CLI enum `Commands` to include `Cooling` and dispatch handling - Refine env_logger formatting to output only `[LEVEL] message` - Integrate cooling execution into the main command dispatch flow - Bug Fixes - No bug fixes introduced in this change --- src/cli.rs | 15 +++++++++++++++ src/main.rs | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index eb17529..89b9733 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -32,6 +32,11 @@ pub enum Commands { #[command(subcommand)] command: PowerCommands, }, + /// Cooling and thermal management + Cooling { + #[command(subcommand)] + command: CoolingCommands, + }, /// Hardware status Status, } @@ -91,6 +96,16 @@ pub enum PowerCommands { BatterySave, } +#[derive(Subcommand, Debug)] +pub enum CoolingCommands { + /// Set extreme performance fan/thermal mode + Performance, + /// Set balanced/intelligent cooling mode + Balanced, + /// Set quiet/battery saving fan mode + Quiet, +} + #[derive(Subcommand, Debug)] pub enum BatteryCommands { /// Set the battery charging limit (e.g., 80) diff --git a/src/main.rs b/src/main.rs index 122e9e7..4265ad7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,16 +16,20 @@ fn main() { log::LevelFilter::Info }; + use std::io::Write; env_logger::Builder::new() .filter_level(level) - .format_timestamp(None) - .format_module_path(false) + .format(|buf, record| { + // Write only [LEVEL] message + writeln!(buf, "[{}] {}", record.level(), record.args()) + }) .init(); match &cli.command { Commands::Gpu { command } => commands::gpu::execute(command), Commands::Battery { command } => commands::battery::execute(command), Commands::Power { command } => commands::power::execute(command), + Commands::Cooling { command } => commands::cooling::execute(command), Commands::Status => commands::status::execute(), } }