From 0ee4493cbef84cad54af6befbdcebdbc1a24846c Mon Sep 17 00:00:00 2001 From: Colin Cai Date: Sat, 18 May 2024 11:13:03 -0400 Subject: [PATCH] ravedude: fix open_console serialization & tweak error messages --- ravedude/src/config.rs | 1 + ravedude/src/main.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ravedude/src/config.rs b/ravedude/src/config.rs index 3d7a809f73..94a795ba74 100644 --- a/ravedude/src/config.rs +++ b/ravedude/src/config.rs @@ -64,6 +64,7 @@ impl RavedudeConfig { #[derive(serde::Serialize, serde::Deserialize, Debug, Default)] #[serde(rename_all = "kebab-case")] pub struct RavedudeGeneralConfig { + #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub open_console: bool, pub serial_baudrate: Option, pub port: Option, diff --git a/ravedude/src/main.rs b/ravedude/src/main.rs index f461a8aa30..8111915029 100644 --- a/ravedude/src/main.rs +++ b/ravedude/src/main.rs @@ -125,9 +125,12 @@ fn ravedude() -> anyhow::Result<()> { anyhow::bail!("can't pass board as command-line argument when Ravedude.toml is present; set `board = {:?}` under [general] in Ravedude.toml", board) } } - } else if args.board.is_some() { + } else if args.board.is_some() && !args.dump_config { warning!( - "Passing the board as command-line argument is deprecated, use Ravedude.toml instead:\n\n# Ravedude.toml\n{}", + "Passing the board as command-line argument is deprecated, use Ravedude.toml instead:" + ); + eprintln!( + "\n# Ravedude.toml\n{}", toml::to_string(&config::RavedudeConfig::from_args(&args)?)? ); } @@ -144,6 +147,8 @@ fn ravedude() -> anyhow::Result<()> { )? }; + ravedude_config.general_options.apply_overrides(&mut args)?; + if args.dump_config { println!("{}", toml::to_string(&ravedude_config)?); return Ok(()); @@ -151,8 +156,6 @@ fn ravedude() -> anyhow::Result<()> { avrdude::Avrdude::require_min_ver(MIN_VERSION_AVRDUDE)?; - ravedude_config.general_options.apply_overrides(&mut args)?; - let Some(mut board) = ravedude_config.board_config else { anyhow::bail!("no named board given and no board options provided"); };