From e633c1a5dae0c1e36c884dd6421b5b52abb91313 Mon Sep 17 00:00:00 2001 From: Vasilii Demidenok <879658+define-null@users.noreply.github.com> Date: Fri, 17 May 2024 21:33:40 +0200 Subject: [PATCH] Expose Editor in the API --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 767c3e6..7caf161 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ use rustyline::{ Event, Helper, KeyCode, KeyEvent, Modifiers, }; -struct ClapEditorHelper<C: Parser> { +pub struct ClapEditorHelper<C: Parser> { c_phantom: PhantomData<C>, } @@ -77,6 +77,10 @@ impl<C: Parser> ClapEditor<C> { Self::construct(prompt.into()) } + pub fn get_editor(&mut self) -> &mut Editor<ClapEditorHelper<C>, rustyline::history::FileHistory> { + &mut self.rl + } + pub fn read_command(&mut self) -> Option<C> { let line = match self.rl.readline(&self.prompt) { Ok(x) => x,