Skip to content

Commit

Permalink
Merge pull request #5 from define-null/defnull/expose-editor-in-api
Browse files Browse the repository at this point in the history
Expose Editor in the API
  • Loading branch information
HKalbasi committed May 18, 2024
2 parents 7a35234 + e633c1a commit 27f0e03
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustyline::{
Event, Helper, KeyCode, KeyEvent, Modifiers,
};

struct ClapEditorHelper<C: Parser> {
pub struct ClapEditorHelper<C: Parser> {
c_phantom: PhantomData<C>,
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 27f0e03

Please sign in to comment.