From e775420d4c8b0355243de8e86b974082b3cd0ccd Mon Sep 17 00:00:00 2001 From: Rahix Date: Sat, 14 Sep 2024 11:15:30 +0200 Subject: [PATCH] ravedude: Fix backwards compatibility with legacy configuration Need to use `legacy_bin` as the binary in the legacy configuration mode. --- ravedude/src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ravedude/src/main.rs b/ravedude/src/main.rs index 781d475f64..d34b77e44c 100644 --- a/ravedude/src/main.rs +++ b/ravedude/src/main.rs @@ -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() { @@ -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);