From: Vihiga Tyonum Date: Mon, 6 Jul 2026 15:36:33 +0000 (+0000) Subject: fix(repl): Remove null printed after repl output X-Git-Url: http://internal-gitweb-vhost/blockdata/script/encode/-script/display/MiniscriptException.TrNoScriptCode.html?a=commitdiff_plain;h=f17a7ef871f6cec7c662d582bd46e11cba072c55;p=bdk-cli fix(repl): Remove null printed after repl output --- diff --git a/src/handlers/repl.rs b/src/handlers/repl.rs index c2a5ae8..b15b653 100644 --- a/src/handlers/repl.rs +++ b/src/handlers/repl.rs @@ -43,10 +43,7 @@ pub(crate) async fn respond( ) -> Result { let args = shlex::split(line).ok_or("error: Invalid quoting".to_string())?; - let mut repl_args = vec!["repl".to_string()]; - repl_args.extend(args); - - let repl_subcommand = match ReplSubCommand::try_parse_from(&repl_args) { + let repl_subcommand = match ReplSubCommand::try_parse_from(&args) { Ok(cmd) => cmd, Err(e) => { writeln!(std::io::stdout(), "{}", e).map_err(|e| e.to_string())?; @@ -58,10 +55,7 @@ pub(crate) async fn respond( ReplSubCommand::Wallet { subcommand } => match subcommand { WalletSubCommand::OfflineWalletSubCommand(cmd) => { let mut ctx = AppContext::new_offline_wallet(network, datadir, wallet); - cmd.execute(&mut ctx) - .map_err(|e| e.to_string())? - .write_out(std::io::stdout()) - .map_err(|e| e.to_string())?; + cmd.execute(&mut ctx).map_err(|e| e.to_string())?; Some(()) } #[cfg(any( @@ -80,20 +74,16 @@ pub(crate) async fn respond( wallet_name.to_string(), ); - cmd.execute(&mut ctx) - .await - .map_err(|e| e.to_string())? - .write_out(std::io::stdout()) - .map_err(|e| e.to_string())?; + cmd.execute(&mut ctx).await.map_err(|e| e.to_string())?; Some(()) } - WalletSubCommand::Config(config_cmd) => { - let mut ctx = AppContext::new(network, datadir); - config_cmd - .execute(&mut ctx) - .map_err(|e| e.to_string())? - .write_out(std::io::stdout()) - .map_err(|e| e.to_string())?; + WalletSubCommand::Config(_) => { + writeln!( + std::io::stdout(), + "`config` is not available in REPL mode — the wallet for this session \ + is already loaded. Exit and run `bdk-cli wallet --wallet config ...`." + ) + .map_err(|e| e.to_string())?; Some(()) } },