taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit e8a8977ada44fe6015d5a50eb8db63e3dfe693f2
parent 07ae2275a7ebf94b3d413430a69ca9caff4115d7
Author: Antoine A <>
Date:   Tue, 23 Jun 2026 11:31:41 +0200

test: improve repl

Diffstat:
Mcommon/taler-test-utils/src/repl.rs | 25+++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/common/taler-test-utils/src/repl.rs b/common/taler-test-utils/src/repl.rs @@ -16,7 +16,6 @@ use std::{borrow::Cow, marker::PhantomData}; -use clap::Command; use nu_ansi_term::Color; use reedline::{ ColumnarMenu, DefaultHinter, FileBackedHistory, KeyCode, KeyModifiers, MenuBuilder as _, @@ -27,7 +26,6 @@ use reedline::{ use crate::cli::clap_parse; pub struct Repl<T: clap::Parser> { - cmd: Command, relp: Reedline, phantom: PhantomData<T>, } @@ -55,10 +53,9 @@ impl<T: clap::Parser> Repl<T> { ReedlineEvent::MenuNext, ]), ); - let cmd = T::command(); let repl = Reedline::create() .with_history(history) - .with_completer(Box::new(ClapCompleter(cmd.clone()))) + .with_completer(Box::new(ClapCompleter(T::command().clone()))) .with_menu(ReedlineMenu::EngineCompleter(completion_menu)) .with_quick_completions(true) .with_partial_completions(true) @@ -68,7 +65,6 @@ impl<T: clap::Parser> Repl<T> { .with_edit_mode(Box::new(Vi::new(insert, default_vi_normal_keybindings()))); Self { - cmd, relp: repl, phantom: PhantomData, } @@ -80,25 +76,14 @@ impl<T: clap::Parser> Repl<T> { else { return None; }; - if buf.trim().is_empty() { - self.print_commands(); - } else { - match clap_parse(&buf) { - Ok(cmd) => return Some(cmd), - Err(_) => { - self.print_commands(); - } + match clap_parse(&buf) { + Ok(cmd) => return Some(cmd), + Err(e) => { + e.print().unwrap(); } } } } - - fn print_commands(&self) { - for sub in self.cmd.get_subcommands() { - let about = sub.get_about().unwrap_or_default(); - println!("{:<10} {}", sub.get_name(), about); - } - } } struct ClapCompleter(clap::Command);