]> Untitled Git - bdk-cli/commitdiff
fix(repl): Remove null printed after repl output
authorVihiga Tyonum <withtvpeter@gmail.com>
Mon, 6 Jul 2026 15:36:33 +0000 (15:36 +0000)
committerVihiga Tyonum <withtvpeter@gmail.com>
Wed, 8 Jul 2026 21:49:31 +0000 (22:49 +0100)
src/handlers/repl.rs

index c2a5ae85270b158d24de3b9d232665c07193e290..b15b653f16f0639742a74995ecaad411e11f676a 100644 (file)
@@ -43,10 +43,7 @@ pub(crate) async fn respond(
 ) -> Result<bool, String> {
     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 <name> config ...`."
+                )
+                .map_err(|e| e.to_string())?;
                 Some(())
             }
         },