Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the 'ble' and 'wifi' options mutually exclusive #23

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,17 +391,24 @@ fn process_options(args: &Args) {
for option in &args.option {
// Find the matching option in OPTIONS
if let Some(option_item) = OPTIONS.iter().find(|item| item.name() == *option) {
// Check if the chip is supported. If the chip list is empty, all chips are supported
// Check if the chip is supported. If the chip list is empty,
// all chips are supported:
if !option_item.chips().iter().any(|chip| chip == &args.chip)
&& !option_item.chips().is_empty()
{
eprintln!(
"Error: Option {:?} is not supported for chip {:?}",
"Error: Option '{}' is not supported for chip {}",
option, args.chip
);
process::exit(-1);
}
}
}

if args.option.contains(&String::from("ble")) && args.option.contains(&String::from("wifi")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine but I was hoping we could detect such a situation more generally by checking the disables field in GeneratorOption

But given this is not a general-purpose library to create project generators it's probably unnecessary to deal with that

Copy link
Member Author

@jessebraham jessebraham Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider a more thorough solution, but for the time being this at least solves the linked issue. Can revisit it at a later date.

eprintln!("Error: Options 'ble' and 'wifi' are mutually exclusive");
process::exit(-1);
}
}

#[cfg(test)]
Expand Down