Skip to content

Commit

Permalink
ravedude: Fix backwards compatibility with legacy configuration
Browse files Browse the repository at this point in the history
Need to use `legacy_bin` as the binary in the legacy configuration mode.
  • Loading branch information
Rahix committed Sep 14, 2024
1 parent 346920b commit 416bd01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ravedude/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ impl Args {
.and_then(|board| board.to_str().map(String::from))
}
}

/// Get the binary argument with fallback for the legacy menchanism.
///
/// Returns `None` if no binary argument was passed.
fn bin_or_legacy_bin(&self) -> Option<&std::path::Path> {
self.bin_legacy
.as_ref()
.map(|p| p.as_path())
.or(self.bin.as_ref().map(|p| p.as_path()))
}
}

fn main() {
Expand Down Expand Up @@ -178,7 +188,7 @@ fn ravedude() -> anyhow::Result<()> {
},
}?;

if let Some(bin) = args.bin.as_ref() {
if let Some(bin) = args.bin_or_legacy_bin() {
if let Some(wait_time) = args.reset_delay {
if wait_time > 0 {
println!("Waiting {} ms before proceeding", wait_time);
Expand Down

0 comments on commit 416bd01

Please sign in to comment.