Skip to content

Commit

Permalink
chwd: Remove USB options
Browse files Browse the repository at this point in the history
We're not handling it properly right now
  • Loading branch information
ventureoo committed Aug 20, 2024
1 parent 8f606d4 commit fbcd093
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ pub struct Args {
pub show_pci: bool,

/// Install profile
#[arg(short, long, number_of_values = 2, value_names = &["usb/pci", "profile"], conflicts_with("remove"))]
#[arg(short, long, value_name = "profile", conflicts_with("remove"))]
pub install: Option<Vec<String>>,

/// Remove profile
#[arg(short, long, number_of_values = 2, value_names = &["usb/pci", "profile"], conflicts_with("install"))]
#[arg(short, long, value_name = "profile", conflicts_with("install"))]
pub remove: Option<Vec<String>>,

/// Show detailed info for listings
Expand All @@ -54,7 +54,7 @@ pub struct Args {
pub list_all: bool,

/// Autoconfigure
#[arg(short, long, number_of_values = 2, value_names = &["usb/pci", "classid"], conflicts_with_all(["install", "remove"]))]
#[arg(short, long, value_name = "classid", conflicts_with_all(["install", "remove"]))]
pub autoconfigure: Option<Vec<String>>,

/// Print if nvidia card found
Expand Down
25 changes: 5 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,10 @@ use subprocess::Exec;

fn perceed_inst_rem(
args: &Option<Vec<String>>,
operation: &mut String,
working_profiles: &mut Vec<String>,
) -> anyhow::Result<()> {
if let Some(values) = args {
let device_type = &values[0];
let profile = values[1].to_lowercase();

if "pci" != device_type && "usb" != device_type {
anyhow::bail!("invalid use of option: {args:?}");
}
*operation = device_type.to_uppercase();
let profile = values[0].to_lowercase();
working_profiles.push(profile);
}

Expand All @@ -58,17 +51,10 @@ fn perceed_inst_rem(

fn perceed_autoconf(
args: &Option<Vec<String>>,
operation: &mut String,
autoconf_class_id: &mut String,
) -> anyhow::Result<()> {
if let Some(values) = args {
let device_type = &values[0];
*autoconf_class_id = values[1].to_lowercase();

if "pci" != device_type && "usb" != device_type {
anyhow::bail!("invalid use of option: {args:?}");
}
*operation = device_type.to_uppercase();
*autoconf_class_id = values[0].to_lowercase();
}

Ok(())
Expand Down Expand Up @@ -97,15 +83,14 @@ fn main() -> anyhow::Result<()> {

let mut working_profiles: Vec<String> = vec![];

let mut operation = String::new();
let mut autoconf_class_id = String::new();
perceed_autoconf(
&argstruct.autoconfigure,
&mut operation,
&mut autoconf_class_id,
)?;
perceed_inst_rem(&argstruct.install, &mut operation, &mut working_profiles)?;
perceed_inst_rem(&argstruct.remove, &mut operation, &mut working_profiles)?;

perceed_inst_rem(&argstruct.install, &mut working_profiles)?;
perceed_inst_rem(&argstruct.remove, &mut working_profiles)?;

if !argstruct.show_pci {
argstruct.show_pci = true;
Expand Down

0 comments on commit fbcd093

Please sign in to comment.