Struct easy_repl::repl::ReplBuilder[][src]

pub struct ReplBuilder<'a> { /* fields omitted */ }
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

impl<'a> ReplBuilder<'a>[src]

pub fn description<T: Into<String>>(self, v: T) -> Self[src]

Repl description shown in Repl::help. Defaults to an empty string.

pub fn prompt<T: Into<String>>(self, v: T) -> Self[src]

Prompt string, defaults to "> ".

pub fn text_width<T: Into<usize>>(self, v: T) -> Self[src]

Width of the text used when wrapping the help message. Defaults to 80.

pub fn editor_config<T: Into<Config>>(self, v: T) -> Self[src]

Configuration for rustyline. Some sane defaults are used.

pub fn out<T: Into<Box<dyn Write>>>(self, v: T) -> Self[src]

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).

pub fn with_hints<T: Into<bool>>(self, v: T) -> Self[src]

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|ve

but when there is only

> m|

then no hints will be shown.

pub fn with_completion<T: Into<bool>>(self, v: T) -> Self[src]

Use completion. Defaults to true.

pub fn with_filename_completion<T: Into<bool>>(self, v: T) -> Self[src]

Add filename completion, besides command completion. Defaults to false.

pub fn predict_commands<T: Into<bool>>(self, v: T) -> Self[src]

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.

pub fn add(self, name: &str, cmd: Command<'a>) -> Self[src]

Add a command with given name. Use along with the command! macro.

pub fn build(self) -> Result<Repl<'a>, BuilderError>[src]

Finalize the configuration and return the REPL or error.

Trait Implementations

impl<'a> Default for ReplBuilder<'a>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.