From 00b7c6482f67615b5059f9fd11370dae90659b00 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 1 Aug 2021 00:15:38 +1200 Subject: [PATCH] fix: remove the parsing for root supported functions --- asusctl/src/main.rs | 54 -------------------------- daemon/src/ctrl_profiles/controller.rs | 1 - 2 files changed, 55 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index d4a0a301..559eb2ac 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -14,7 +14,6 @@ use rog_types::{ gfx_vendors::{GfxRequiredUserAction, GfxVendors}, supported::{ FanCpuSupportedFunctions, LedSupportedFunctions, RogBiosSupportedFunctions, - SupportedFunctions, }, }; use std::{env::args, path::Path}; @@ -133,12 +132,6 @@ fn main() -> Result<(), Box> { let supported = dbus.proxies().supported().get_supported_functions()?; - if parsed.help { - print_supported_help(&supported, &parsed); - println!("\nSee https://asus-linux.org/faq/ for additional help"); - std::process::exit(1); - } - if parsed.version { println!(" asusctl v{}", env!("CARGO_PKG_VERSION")); println!(" rog-dbus v{}", rog_dbus::VERSION); @@ -234,53 +227,6 @@ fn main() -> Result<(), Box> { Ok(()) } -/// Print the root help for base commands if the commands are supported -fn print_supported_help(supported: &SupportedFunctions, parsed: &CliStart) { - // As help option don't work with `parse_args_default` - // we will call `parse_args_default_or_exit` instead - let usage: Vec = parsed.self_usage().lines().map(|s| s.to_string()).collect(); - for line in usage.iter().filter(|line| { - if line.contains("--fan-mode") && !supported.fan_cpu_ctrl.stock_fan_modes { - return false; - } - if line.contains("--chg-limit") && !supported.charge_ctrl.charge_level_set { - return false; - } - true - }) { - println!("{}", line); - } - - // command strings are in order of the struct - let commands: Vec = CliCommand::usage().lines().map(|s| s.to_string()).collect(); - println!("\nCommands available"); - for line in commands.iter().filter(|line| { - if line.contains("profile") { - return supported.fan_cpu_ctrl.stock_fan_modes || supported.fan_cpu_ctrl.fan_curve_set; - } - if line.contains("led-mode") { - return supported.keyboard_led.stock_led_modes.is_empty(); - } - if line.contains("bios") { - return supported.rog_bios_ctrl.dedicated_gfx_toggle - || supported.rog_bios_ctrl.post_sound_toggle; - } - if line.contains("anime") { - return supported.anime_ctrl.0; - } - false - }) { - println!("{}", line); - } - - if !supported.fan_cpu_ctrl.stock_fan_modes { - println!("Note: Fan mode control is not supported by this laptop"); - } - if !supported.charge_ctrl.charge_level_set { - println!("Note: Charge control is not supported by this laptop"); - } -} - fn do_gfx( dbus: &RogDbusClient, supported: &RogBiosSupportedFunctions, diff --git a/daemon/src/ctrl_profiles/controller.rs b/daemon/src/ctrl_profiles/controller.rs index aba0f5f9..e6cd3791 100644 --- a/daemon/src/ctrl_profiles/controller.rs +++ b/daemon/src/ctrl_profiles/controller.rs @@ -1,7 +1,6 @@ use crate::error::RogError; use crate::{config::Config, GetSupported}; use log::{info, warn}; -use rog_profiles::error::ProfileError; use rog_profiles::profiles::Profile; use rog_types::supported::FanCpuSupportedFunctions; use std::sync::Arc;