mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
feat: reorder CLI parameters
This commit is contained in:
@@ -8,7 +8,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed};
|
|||||||
#[derive(FromArgs, Debug, Clone)]
|
#[derive(FromArgs, Debug, Clone)]
|
||||||
#[argh(
|
#[argh(
|
||||||
subcommand,
|
subcommand,
|
||||||
name = "aura-power-old",
|
name = "power-tuf",
|
||||||
description = "aura power (old ROGs and TUF laptops)"
|
description = "aura power (old ROGs and TUF laptops)"
|
||||||
)]
|
)]
|
||||||
pub struct LedPowerCommand1 {
|
pub struct LedPowerCommand1 {
|
||||||
@@ -38,7 +38,7 @@ pub struct LedPowerCommand1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromArgs, Debug, Clone)]
|
#[derive(FromArgs, Debug, Clone)]
|
||||||
#[argh(subcommand, name = "aura-power", description = "aura power")]
|
#[argh(subcommand, name = "power", description = "aura power")]
|
||||||
pub struct LedPowerCommand2 {
|
pub struct LedPowerCommand2 {
|
||||||
#[argh(subcommand)]
|
#[argh(subcommand)]
|
||||||
pub command: Option<SetAuraZoneEnabled>,
|
pub command: Option<SetAuraZoneEnabled>,
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ pub struct CliStart {
|
|||||||
#[derive(FromArgs, Debug)]
|
#[derive(FromArgs, Debug)]
|
||||||
#[argh(subcommand)]
|
#[argh(subcommand)]
|
||||||
pub enum CliCommand {
|
pub enum CliCommand {
|
||||||
Aura(LedModeCommand),
|
Aura(AuraCommand),
|
||||||
AuraPowerOld(LedPowerCommand1),
|
|
||||||
AuraPower(LedPowerCommand2),
|
|
||||||
Brightness(BrightnessCommand),
|
Brightness(BrightnessCommand),
|
||||||
Profile(ProfileCommand),
|
Profile(ProfileCommand),
|
||||||
FanCurve(FanCurveCommand),
|
FanCurve(FanCurveCommand),
|
||||||
@@ -99,7 +97,7 @@ pub struct ProfileSetCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(FromArgs, Debug, Default)]
|
#[derive(FromArgs, Debug, Default)]
|
||||||
#[argh(subcommand, name = "aura", description = "led mode commands")]
|
#[argh(subcommand, name = "effect", description = "led mode commands")]
|
||||||
pub struct LedModeCommand {
|
pub struct LedModeCommand {
|
||||||
#[argh(switch, description = "switch to next aura mode")]
|
#[argh(switch, description = "switch to next aura mode")]
|
||||||
pub next_mode: bool,
|
pub next_mode: bool,
|
||||||
@@ -111,6 +109,21 @@ pub struct LedModeCommand {
|
|||||||
pub command: Option<SetAuraBuiltin>,
|
pub command: Option<SetAuraBuiltin>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(FromArgs, Debug)]
|
||||||
|
#[argh(subcommand, name = "aura", description = "aura device commands")]
|
||||||
|
pub struct AuraCommand {
|
||||||
|
#[argh(subcommand)]
|
||||||
|
pub command: AuraSubCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(FromArgs, Debug)]
|
||||||
|
#[argh(subcommand)]
|
||||||
|
pub enum AuraSubCommand {
|
||||||
|
Power(LedPowerCommand2),
|
||||||
|
PowerTuf(LedPowerCommand1),
|
||||||
|
Effect(LedModeCommand),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(FromArgs, Debug, Default)]
|
#[derive(FromArgs, Debug, Default)]
|
||||||
#[argh(
|
#[argh(
|
||||||
subcommand,
|
subcommand,
|
||||||
|
|||||||
@@ -186,9 +186,11 @@ fn do_parsed(
|
|||||||
conn: Connection,
|
conn: Connection,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
match &parsed.command {
|
match &parsed.command {
|
||||||
CliCommand::Aura(mode) => handle_led_mode(mode)?,
|
CliCommand::Aura(a) => match &a.command {
|
||||||
CliCommand::AuraPowerOld(pow) => handle_led_power1(pow)?,
|
crate::cli_opts::AuraSubCommand::Effect(mode) => handle_led_mode(mode)?,
|
||||||
CliCommand::AuraPower(pow) => handle_led_power2(pow)?,
|
crate::cli_opts::AuraSubCommand::PowerTuf(pow) => handle_led_power1(pow)?,
|
||||||
|
crate::cli_opts::AuraSubCommand::Power(pow) => handle_led_power2(pow)?,
|
||||||
|
},
|
||||||
CliCommand::Brightness(cmd) => handle_brightness(cmd)?,
|
CliCommand::Brightness(cmd) => handle_brightness(cmd)?,
|
||||||
CliCommand::Profile(cmd) => handle_throttle_profile(&conn, supported_properties, cmd)?,
|
CliCommand::Profile(cmd) => handle_throttle_profile(&conn, supported_properties, cmd)?,
|
||||||
CliCommand::FanCurve(cmd) => handle_fan_curve(&conn, cmd)?,
|
CliCommand::FanCurve(cmd) => handle_fan_curve(&conn, cmd)?,
|
||||||
@@ -720,7 +722,7 @@ fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error:
|
|||||||
&& !power.keyboard
|
&& !power.keyboard
|
||||||
&& !power.lightbar
|
&& !power.lightbar
|
||||||
{
|
{
|
||||||
println!("Missing arg or command; run 'asusctl aura-power-old --help' for usage");
|
println!("Missing arg or command; run 'asusctl aura power-tuf --help' for usage");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,7 +775,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if power.command.is_none() {
|
if power.command.is_none() {
|
||||||
println!("Missing arg or command; run 'asusctl aura-power --help' for usage");
|
println!("Missing arg or command; run 'asusctl aura power --help' for usage");
|
||||||
println!("Commands available");
|
println!("Commands available");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user