Skip to content

Commit

Permalink
chwd: Make arguments for autoconfigure optional
Browse files Browse the repository at this point in the history
It allows us to replace install-gpu-drivers script in calamares just by
running ``chwd --autoconfigure``.
  • Loading branch information
ventureoo committed Aug 21, 2024
1 parent 964cd61 commit a1372e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Toggle AI SDK profiles
Expand Down
8 changes: 6 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit a1372e4

Please sign in to comment.