From a1372e4f4f5d727bbb70a2c9972a808642275124 Mon Sep 17 00:00:00 2001 From: Vasiliy Stelmachenok Date: Wed, 21 Aug 2024 20:30:57 +0300 Subject: [PATCH] chwd: Make arguments for autoconfigure optional It allows us to replace install-gpu-drivers script in calamares just by running ``chwd --autoconfigure``. --- src/args.rs | 2 +- src/main.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/args.rs b/src/args.rs index 710b8d5..81b5fb8 100644 --- a/src/args.rs +++ b/src/args.rs @@ -51,7 +51,7 @@ pub struct Args { pub list_all: bool, /// Autoconfigure - #[arg(short, long, value_name = "classid", conflicts_with_all(["install", "remove"]))] + #[arg(short, long, value_name = "classid", conflicts_with_all(["install", "remove"]), default_missing_value = "any", num_args(0..=1), require_equals = true)] pub autoconfigure: Option, /// Toggle AI SDK profiles diff --git a/src/main.rs b/src/main.rs index 0c37740..408f578 100644 --- a/src/main.rs +++ b/src/main.rs @@ -165,7 +165,7 @@ fn prepare_autoconfigure( let mut found_device = false; for device in devices.iter() { - if device.class_id != autoconf_class_id { + if autoconf_class_id != "any" && device.class_id != autoconf_class_id { continue; } found_device = true; @@ -182,7 +182,11 @@ fn prepare_autoconfigure( device.device_name ); if profile.is_none() { - console_writer::print_warning(&format!("No config found for device: {device_info}")); + if autoconf_class_id != "any" { + console_writer::print_warning(&format!( + "No config found for device: {device_info}" + )); + } continue; } let profile = profile.unwrap();