- New Features - Added `temperature` subcommand to display system temperatures. - Added `fan` subcommand to display fan speeds. - Added `power` subcommand under GPU commands to show GPU power state and consumption. - Enhancements - Integrated new subcommands into the command dispatcher. - Bug Fixes - None
52 lines
1.7 KiB
Rust
52 lines
1.7 KiB
Rust
use clap::Parser;
|
|
|
|
use lapctl::cli::{Cli, Commands};
|
|
use lapctl::commands;
|
|
|
|
fn main() {
|
|
let cli = Cli::parse();
|
|
|
|
let level = if cli.verbose {
|
|
log::LevelFilter::Debug
|
|
} else {
|
|
log::LevelFilter::Info
|
|
};
|
|
|
|
use std::io::Write;
|
|
env_logger::Builder::new()
|
|
.filter_level(level)
|
|
.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::Display { command } => commands::display::execute(command),
|
|
Commands::Status => commands::status::execute(),
|
|
Commands::Temperature => commands::temperature::execute(),
|
|
Commands::Fan => commands::fan::execute(),
|
|
Commands::InstallRules => commands::install_rules::execute(),
|
|
Commands::Touchpad { command } => commands::touchpad::execute(command),
|
|
Commands::Daemon => {
|
|
let rt = match tokio::runtime::Runtime::new() {
|
|
Ok(rt) => rt,
|
|
Err(e) => {
|
|
eprintln!("Failed to create tokio runtime: {}", e);
|
|
std::process::exit(1);
|
|
}
|
|
};
|
|
rt.block_on(async {
|
|
if let Err(e) = lapctl::daemon::run().await {
|
|
eprintln!("Daemon error: {}", e);
|
|
std::process::exit(1);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|