From 9366b0ec048ade82156cbadd333ebe48b2a3dbfc Mon Sep 17 00:00:00 2001 From: yanganto Date: Mon, 20 Oct 2025 00:40:54 +0000 Subject: [PATCH] Allow flexible profile cli input for LowPower --- rog-platform/src/platform.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/rog-platform/src/platform.rs b/rog-platform/src/platform.rs index 481c66f6..e30dbbcb 100644 --- a/rog-platform/src/platform.rs +++ b/rog-platform/src/platform.rs @@ -275,11 +275,16 @@ impl std::str::FromStr for PlatformProfile { type Err = PlatformError; fn from_str(profile: &str) -> Result { - match profile.to_ascii_lowercase().trim() { + match profile + .to_ascii_lowercase() + .trim() + .replace(|c| !char::is_alphabetic(c), "") + .as_str() + { "balanced" => Ok(PlatformProfile::Balanced), "performance" => Ok(PlatformProfile::Performance), "quiet" => Ok(PlatformProfile::Quiet), - "low-power" => Ok(PlatformProfile::LowPower), + "lowpower" => Ok(PlatformProfile::LowPower), "custom" => Ok(PlatformProfile::Custom), _ => Err(PlatformError::NotSupported), } @@ -288,11 +293,16 @@ impl std::str::FromStr for PlatformProfile { impl From<&str> for PlatformProfile { fn from(profile: &str) -> Self { - match profile.to_ascii_lowercase().trim() { + match profile + .to_ascii_lowercase() + .trim() + .replace(|c| !char::is_alphabetic(c), "") + .as_str() + { "balanced" => PlatformProfile::Balanced, "performance" => PlatformProfile::Performance, "quiet" => PlatformProfile::Quiet, - "low-power" => PlatformProfile::LowPower, + "lowpower" => PlatformProfile::LowPower, "custom" => PlatformProfile::Custom, _ => { warn!("{profile} is unknown, using ThrottlePolicy::Balanced");