mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
feat: improve cmdline
This commit is contained in:
@@ -10,9 +10,6 @@ use crate::slash_cli::SlashCommand;
|
||||
#[derive(FromArgs, Default, Debug)]
|
||||
/// asusctl command-line options
|
||||
pub struct CliStart {
|
||||
#[argh(switch, description = "show program version number")]
|
||||
pub version: bool,
|
||||
|
||||
#[argh(switch, description = "show supported functions of this laptop")]
|
||||
pub show_supported: bool,
|
||||
|
||||
@@ -49,6 +46,7 @@ pub enum CliCommand {
|
||||
Scsi(ScsiCommand),
|
||||
Armoury(ArmouryCommand),
|
||||
Backlight(BacklightCommand),
|
||||
Info(InfoCommand),
|
||||
}
|
||||
|
||||
#[derive(FromArgs, Debug, Clone, Default)]
|
||||
@@ -126,3 +124,11 @@ pub struct BacklightCommand {
|
||||
)]
|
||||
pub sync_screenpad_brightness: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(FromArgs, Debug, Default)]
|
||||
#[argh(
|
||||
subcommand,
|
||||
name = "info",
|
||||
description = "show program version and system info"
|
||||
)]
|
||||
pub struct InfoCommand {}
|
||||
|
||||
@@ -54,8 +54,6 @@ fn main() {
|
||||
.format_timestamp(None)
|
||||
.init();
|
||||
|
||||
let self_version = env!("CARGO_PKG_VERSION");
|
||||
println!("Starting version {self_version}");
|
||||
let parsed: CliStart = argh::from_env();
|
||||
|
||||
let conn = Connection::system().unwrap();
|
||||
@@ -75,6 +73,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
let self_version = env!("CARGO_PKG_VERSION");
|
||||
if asusd_version != self_version {
|
||||
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
|
||||
return;
|
||||
@@ -95,12 +94,6 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
if parsed.version {
|
||||
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
||||
println!();
|
||||
print_info();
|
||||
}
|
||||
|
||||
if let Err(err) = do_parsed(&parsed, &supported_interfaces, &supported_properties, conn) {
|
||||
print_error_help(&*err, &supported_interfaces, &supported_properties);
|
||||
}
|
||||
@@ -127,9 +120,9 @@ fn print_info() {
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
let board_name = dmi.board_name;
|
||||
let prod_family = dmi.product_family;
|
||||
println!("asusctl version: {}", env!("CARGO_PKG_VERSION"));
|
||||
println!(" Product family: {}", prod_family.trim());
|
||||
println!(" Board name: {}", board_name.trim());
|
||||
println!("Software version: {}", env!("CARGO_PKG_VERSION"));
|
||||
println!(" Product family: {}", prod_family.trim());
|
||||
println!(" Board name: {}", board_name.trim());
|
||||
}
|
||||
|
||||
fn check_service(name: &str) -> bool {
|
||||
@@ -208,6 +201,11 @@ fn do_parsed(
|
||||
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
|
||||
Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
|
||||
Some(CliCommand::Backlight(cmd)) => handle_backlight(cmd)?,
|
||||
Some(CliCommand::Info(_)) => {
|
||||
println!("asusctl v{}", env!("CARGO_PKG_VERSION"));
|
||||
println!();
|
||||
print_info();
|
||||
}
|
||||
None => {
|
||||
if !parsed.show_supported
|
||||
&& parsed.kbd_bright.is_none()
|
||||
|
||||
Reference in New Issue
Block a user