feat: improve the cli interface

This commit is contained in:
Denis Benato
2026-01-14 01:56:58 +01:00
parent d7ddee246a
commit 3665d9cc8e
2 changed files with 67 additions and 43 deletions

View File

@@ -216,6 +216,7 @@ pub struct SingleSpeed {
#[argh(
option,
default = "AuraZone::None",
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
@@ -237,6 +238,7 @@ pub struct SingleSpeedDirection {
#[argh(
option,
default = "AuraZone::None",
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
@@ -250,11 +252,12 @@ pub struct SingleSpeedDirection {
description = "static single-colour effect"
)]
pub struct SingleColour {
#[argh(option, description = "set the RGB value e.g. ff00ff")]
#[argh(option, short = 'c', description = "set the RGB value e.g. ff00ff")]
pub colour: Colour,
#[argh(
option,
default = "AuraZone::None",
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
@@ -268,7 +271,7 @@ pub struct SingleColour {
description = "single-colour effect with speed"
)]
pub struct SingleColourSpeed {
#[argh(option, description = "set the RGB value e.g. ff00ff")]
#[argh(option, short = 'c', description = "set the RGB value e.g. ff00ff")]
pub colour: Colour,
#[argh(option, description = "set the speed: low, med, high")]
@@ -276,6 +279,7 @@ pub struct SingleColourSpeed {
#[argh(
option,
default = "AuraZone::None",
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,
@@ -300,6 +304,7 @@ pub struct TwoColourSpeed {
#[argh(
option,
default = "AuraZone::None",
description = "set the zone for this effect e.g. 0, 1, one, logo, lightbar-left"
)]
pub zone: AuraZone,

View File

@@ -198,25 +198,46 @@ fn do_parsed(
CliCommand::Scsi(cmd) => handle_scsi(cmd)?,
CliCommand::Armoury(cmd) => handle_armoury_command(cmd)?,
CliCommand::Backlight(cmd) => handle_backlight(cmd)?,
CliCommand::Battery(cmd) => match &cmd.command {
CliCommand::Battery(cmd) => handle_battery(cmd, &conn)?,
CliCommand::Info(info_opt) => {
handle_info(info_opt, supported_interfaces, supported_properties)?
}
}
Ok(())
}
fn handle_battery(
cmd: &BatteryCommand,
conn: &Connection,
) -> Result<(), Box<dyn std::error::Error>> {
match &cmd.command {
BatterySubCommand::Limit(l) => {
let proxy = PlatformProxyBlocking::new(&conn)?;
let proxy = PlatformProxyBlocking::new(conn)?;
proxy.set_charge_control_end_threshold(l.limit)?;
}
BatterySubCommand::OneShot(o) => {
let proxy = PlatformProxyBlocking::new(&conn)?;
let proxy = PlatformProxyBlocking::new(conn)?;
if let Some(p) = o.percent {
proxy.set_charge_control_end_threshold(p)?;
}
proxy.one_shot_full_charge()?;
}
BatterySubCommand::Info(_) => {
let proxy = PlatformProxyBlocking::new(&conn)?;
let proxy = PlatformProxyBlocking::new(conn)?;
let limit = proxy.charge_control_end_threshold()?;
println!("Current battery charge limit: {}%", limit);
}
},
CliCommand::Info(info_opt) => {
}
Ok(())
}
fn handle_info(
info_opt: &InfoCommand,
supported_interfaces: &[String],
supported_properties: &[Properties],
) -> Result<(), Box<dyn std::error::Error>> {
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
println!();
print_info();
@@ -242,8 +263,6 @@ fn do_parsed(
println!("No aura interface found");
}
}
}
}
Ok(())
}