mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Better print of firmware attributes in CLI
This commit is contained in:
@@ -1075,13 +1075,72 @@ fn handle_platform_new_properties(
|
|||||||
cmd: &PlatformNewCommand,
|
cmd: &PlatformNewCommand,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
{
|
{
|
||||||
if cmd.free.is_empty() || cmd.help {
|
if cmd.free.is_empty() || cmd.free.len() % 2 != 0 || cmd.help {
|
||||||
println!("Missing arg or command\n");
|
const USAGE: &str = "Usage: asusctl platform panel_overdrive 1 nv_dynamic_boost 5";
|
||||||
|
if cmd.free.len() % 2 != 0 {
|
||||||
|
println!(
|
||||||
|
"Incorrect number of args, each attribute label must be paired with a setting:"
|
||||||
|
);
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let usage: Vec<String> = PlatformCommand::usage()
|
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
|
||||||
.lines()
|
println!("\n{USAGE}\n");
|
||||||
.map(|s| s.to_owned())
|
println!("Available firmware attributes: ");
|
||||||
.collect();
|
for attr in attr.iter() {
|
||||||
|
let name = attr.name()?;
|
||||||
|
println!("{name}:");
|
||||||
|
|
||||||
|
let attrs = attr.available_attrs()?;
|
||||||
|
if attrs.contains(&"min_value".to_string())
|
||||||
|
&& attrs.contains(&"max_value".to_string())
|
||||||
|
&& attrs.contains(&"current_value".to_string())
|
||||||
|
{
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
let min = attr.min_value()?;
|
||||||
|
let max = attr.max_value()?;
|
||||||
|
println!(" current: {min}..[{c}]..{max}");
|
||||||
|
if attrs.contains(&"default_value".to_string()) {
|
||||||
|
println!(" default: {}\n", attr.default_value()?);
|
||||||
|
} else {
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
} else if attrs.contains(&"possible_values".to_string())
|
||||||
|
&& attrs.contains(&"current_value".to_string())
|
||||||
|
{
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
let v = attr.possible_values()?;
|
||||||
|
for p in v.iter().enumerate() {
|
||||||
|
if p.0 == 0 {
|
||||||
|
print!(" current: [");
|
||||||
|
}
|
||||||
|
if *p.1 == c {
|
||||||
|
print!("({c})");
|
||||||
|
} else {
|
||||||
|
print!("{}", p.1);
|
||||||
|
}
|
||||||
|
if p.0 < v.len() - 1 {
|
||||||
|
print!(",");
|
||||||
|
}
|
||||||
|
if p.0 == v.len() - 1 {
|
||||||
|
print!("]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if attrs.contains(&"default_value".to_string()) {
|
||||||
|
println!(" default: {}\n", attr.default_value()?);
|
||||||
|
} else {
|
||||||
|
println!("\n");
|
||||||
|
}
|
||||||
|
} else if attrs.contains(&"current_value".to_string()) {
|
||||||
|
let c = attr.current_value()?;
|
||||||
|
println!(" current: {c}\n");
|
||||||
|
} else {
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
|
if let Ok(attr) = find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury") {
|
||||||
|
|||||||
@@ -117,11 +117,6 @@ async fn main() -> Result<()> {
|
|||||||
config.startup_in_background = false;
|
config.startup_in_background = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.startup_in_background {
|
|
||||||
config.run_in_background = true;
|
|
||||||
}
|
|
||||||
config.write();
|
|
||||||
|
|
||||||
let enable_tray_icon = config.enable_tray_icon;
|
let enable_tray_icon = config.enable_tray_icon;
|
||||||
let startup_in_background = config.startup_in_background;
|
let startup_in_background = config.startup_in_background;
|
||||||
let config = Arc::new(Mutex::new(config));
|
let config = Arc::new(Mutex::new(config));
|
||||||
@@ -162,7 +157,6 @@ async fn main() -> Result<()> {
|
|||||||
if let Ok(mut lock) = app_state.lock() {
|
if let Ok(mut lock) = app_state.lock() {
|
||||||
*lock = AppState::MainWindowOpen;
|
*lock = AppState::MainWindowOpen;
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(50));
|
|
||||||
|
|
||||||
let config_copy = config.clone();
|
let config_copy = config.clone();
|
||||||
let app_state_copy = app_state.clone();
|
let app_state_copy = app_state.clone();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"POT-Creation-Date: 2024-12-28 09:01+0000\n"
|
"POT-Creation-Date: 2024-12-28 22:36+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user