Struct easy_repl::repl::ReplBuilder
source · [−]pub struct ReplBuilder<'a> { /* private fields */ }Expand description
Builder pattern implementation for Repl.
All setter methods take owned self so the calls can be chained, for example:
let repl = Repl::builder()
.description("My REPL")
.prompt("repl> ")
.build()
.expect("Failed to build REPL");Implementations
sourceimpl<'a> ReplBuilder<'a>
impl<'a> ReplBuilder<'a>
sourcepub fn description<T: Into<String>>(self, v: T) -> Self
pub fn description<T: Into<String>>(self, v: T) -> Self
Repl description shown in Repl::help. Defaults to an empty string.
sourcepub fn text_width<T: Into<usize>>(self, v: T) -> Self
pub fn text_width<T: Into<usize>>(self, v: T) -> Self
Width of the text used when wrapping the help message. Defaults to 80.
sourcepub fn editor_config<T: Into<Config>>(self, v: T) -> Self
pub fn editor_config<T: Into<Config>>(self, v: T) -> Self
Configuration for rustyline. Some sane defaults are used.
sourcepub fn out<T: Into<Box<dyn Write>>>(self, v: T) -> Self
pub fn out<T: Into<Box<dyn Write>>>(self, v: T) -> Self
Where to print REPL output. By default std::io::Stderr is used.
Note that rustyline will always use std::io::Stderr or std::io::Stdout.
These must be configured in ReplBuilder::editor_config, and currently there seems to be no way
to use other output stream for rustyline (which probably also makes little sense).
sourcepub fn with_hints<T: Into<bool>>(self, v: T) -> Self
pub fn with_hints<T: Into<bool>>(self, v: T) -> Self
Print command hints. Defaults to true.
Hints will show the end of a command if there is only one avaliable.
For example, assuming commands "move" and "make", in the following position (|
indicates the cursor):
> mo|a hint will be shown as
> mo|vebut when there is only
> m|then no hints will be shown.
sourcepub fn with_completion<T: Into<bool>>(self, v: T) -> Self
pub fn with_completion<T: Into<bool>>(self, v: T) -> Self
Use completion. Defaults to true.
sourcepub fn with_filename_completion<T: Into<bool>>(self, v: T) -> Self
pub fn with_filename_completion<T: Into<bool>>(self, v: T) -> Self
Add filename completion, besides command completion. Defaults to false.
sourcepub fn predict_commands<T: Into<bool>>(self, v: T) -> Self
pub fn predict_commands<T: Into<bool>>(self, v: T) -> Self
Execute commands when entering incomplete names. Defaults to true.
With this option commands can be executed by entering only part of command name.
If there is only a single command mathing given prefix, then it will be executed.
For example, with commands "make" and “move”, entering just mo will resolve
to move and the command will be executed, but entering m will result in an error.
sourcepub fn add(self, name: &str, cmd: Command<'a>) -> Self
pub fn add(self, name: &str, cmd: Command<'a>) -> Self
Add a command with given name. Use along with the command! macro.
sourcepub fn build(self) -> Result<Repl<'a>, BuilderError>
pub fn build(self) -> Result<Repl<'a>, BuilderError>
Finalize the configuration and return the REPL or error.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ReplBuilder<'a>
impl<'a> !Send for ReplBuilder<'a>
impl<'a> !Sync for ReplBuilder<'a>
impl<'a> Unpin for ReplBuilder<'a>
impl<'a> !UnwindSafe for ReplBuilder<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more