pub struct Repl<L: LangInterface = DefaultLangInterface> { /* private fields */ }
Expand description
Repl
interacts with the terminal to provide easy interactive shells.
Configuration:
-
leader
What to print as the prompt:> <some-code> ^^- leader
-
continued_leader
If the command is more than one line long, what to print on subsequent lines> <some-code> . <some-code>
-
path
Path to a file to use as persistent history. If given, on construction, the history will be populated from the contents of this file, and will automatically write it to the file on being dropped. In case a path is not specified, the history is lost whenRepl
is dropped. -
capacity
The maximum amount of commands stored in the history. Default capacity is 64. If there are already 64 commands in the history, the oldest one will be forgotten. -
exit_keyword
The keyword to exit the repl, it exits the process, so should not be used if any cleanup is a required before closing repl. Seeset_exit_keyword
-
clear_keyword
Clears the screen. Seeset_clear_keyword
Implementations§
Source§impl<L: LangInterface> Repl<L>
impl<L: LangInterface> Repl<L>
Source§impl Repl<DefaultLangInterface>
impl Repl<DefaultLangInterface>
Source§impl<L: LangInterface> Repl<L>
impl<L: LangInterface> Repl<L>
Sourcepub fn new(
leader: &'static str,
continued_leader: &'static str,
path: Option<PathBuf>,
) -> Self
pub fn new( leader: &'static str, continued_leader: &'static str, path: Option<PathBuf>, ) -> Self
Create a Repl
with specified language interface.
Sourcepub fn with_capacity(
leader: &'static str,
continued_leader: &'static str,
capacity: usize,
path: Option<PathBuf>,
) -> Self
pub fn with_capacity( leader: &'static str, continued_leader: &'static str, capacity: usize, path: Option<PathBuf>, ) -> Self
Create a Repl
with specified language interface, and specified history capacity.
Sourcepub fn set_exit_keyword(&mut self, exit_keyword: &'static str)
pub fn set_exit_keyword(&mut self, exit_keyword: &'static str)
Sets the exit keyword. If you don’t want any exit keyword, set it to an empty string
Sourcepub fn set_clear_keyword(&mut self, clear_keyword: &'static str)
pub fn set_clear_keyword(&mut self, clear_keyword: &'static str)
Sets the clear keyword. If you don’t want any clear keyword, set it to an empty string