From 47432524e185015dc8e180d827c330d95564ec8f Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Wed, 10 Mar 2021 16:01:04 +1300 Subject: [PATCH] Further improve CLI feedback --- asusctl/src/main.rs | 25 +++++++++++++++++++------ daemon/src/ctrl_fan_cpu.rs | 2 +- data/asusd-ledmodes.toml | 8 ++++---- rog-types/src/profile.rs | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index cefda78c..2daa4cf2 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -108,7 +108,7 @@ struct BiosCommand { } fn main() -> Result<(), Box> { - let mut args: Vec = args().skip(1).collect(); + let args: Vec = args().skip(1).collect(); let parsed: CLIStart; let missing_argument_k = gumdrop::Error::missing_argument(Opt::Short('k')); @@ -337,11 +337,19 @@ fn handle_led_mode( if !mode.help { println!("Missing arg or command\n"); } - println!("{}", mode.self_usage()); + println!("{}\n", mode.self_usage()); + println!("Commands available"); - if let Some(lst) = mode.self_command_list() { - println!("\n{}", lst); + let commands: Vec = LedModeCommand::command_list().unwrap().lines().map(|s| s.to_string()).collect(); + for (_, command) in commands.iter().enumerate().filter(|(mode_num, _)| { + if let Some(modes) = supported.stock_led_modes.as_ref() { + return modes.contains(&(*mode_num as u8)) + } + false + }) { + println!("{}", command); } + println!("\nHelp can also be requested on modes, e.g: static --help"); std::process::exit(1); } @@ -368,14 +376,19 @@ fn handle_profile( && cmd.curve.is_none() && cmd.max_percentage.is_none() && cmd.min_percentage.is_none() - && cmd.preset.is_none() + && cmd.fan_preset.is_none() && cmd.profile.is_none() && cmd.turbo.is_none() { if !cmd.help { println!("Missing arg or command\n"); } - println!("{}", cmd.self_usage()); + let usage: Vec = ProfileCommand::usage().lines().map(|s| s.to_string()).collect(); + for line in usage.iter().filter(|line| { + !(line.contains("--curve") && !supported.fan_curve_set) + }) { + println!("{}", line); + } if let Some(lst) = cmd.self_command_list() { println!("\n{}", lst); diff --git a/daemon/src/ctrl_fan_cpu.rs b/daemon/src/ctrl_fan_cpu.rs index d43f2703..da064c8c 100644 --- a/daemon/src/ctrl_fan_cpu.rs +++ b/daemon/src/ctrl_fan_cpu.rs @@ -264,7 +264,7 @@ impl CtrlFanAndCPU { if let Some(max_perc) = command.max_percentage { profile.max_percentage = max_perc; } - if let Some(ref preset) = command.preset { + if let Some(ref preset) = command.fan_preset { profile.fan_preset = preset.into(); } if let Some(ref curve) = command.curve { diff --git a/data/asusd-ledmodes.toml b/data/asusd-ledmodes.toml index 7e855e80..e68caf74 100644 --- a/data/asusd-ledmodes.toml +++ b/data/asusd-ledmodes.toml @@ -1,17 +1,17 @@ [[led_modes]] prod_family = "Zephyrus S" board_names = ["GX502", "GX701", "G531", "GL531", "G532"] -led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 255] +led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 255] [[led_modes]] prod_family = "Zephyrus M" board_names = ["GU502GV"] -led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 255] +led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 255] [[led_modes]] prod_family = "ROG Zephyrus M15" board_names = ["GU502LW"] -led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 255] +led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 255] [[led_modes]] prod_family = "ROG Zephyrus M15" @@ -26,7 +26,7 @@ led_modes = [0, 1, 2, 3, 10, 13] [[led_modes]] prod_family = "ROG Strix" board_names = ["G531GW"] -led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 255] +led_modes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 255] [[led_modes]] prod_family = "ROG Strix" diff --git a/rog-types/src/profile.rs b/rog-types/src/profile.rs index 5d79f172..b6dffe03 100644 --- a/rog-types/src/profile.rs +++ b/rog-types/src/profile.rs @@ -89,7 +89,7 @@ pub struct ProfileCommand { pub max_percentage: Option, #[options(meta = "", help = "")] - pub preset: Option, + pub fan_preset: Option, #[options(meta = "", parse(try_from_str = "parse_fan_curve"), help = "set fan curve")] pub curve: Option, #[options(free)]