[][src]Struct shelp::Repl

pub struct Repl<L: LangInterface = DefaultLangInterface> { /* fields omitted */ }

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 when Repl 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. See set_exit_keyword

  • clear_keyword Clears the screen. See set_clear_keyword

Implementations

impl<L: LangInterface> Repl<L>[src]

pub fn iter(self, color: Color) -> ReplIter<L>

Notable traits for ReplIter<L>

impl<L: LangInterface> Iterator for ReplIter<L> type Item = String;
[src]

Shorthand to get iterator from self

impl Repl<DefaultLangInterface>[src]

pub fn newd(
    leader: &'static str,
    continued_leader: &'static str,
    path: Option<PathBuf>
) -> Self
[src]

Create a Repl with default language interface.

pub fn with_capacityd(
    leader: &'static str,
    continued_leader: &'static str,
    capacity: usize,
    path: Option<PathBuf>
) -> Self
[src]

Create a Repl with default language interface, and specified history capacity.

impl<L: LangInterface> Repl<L>[src]

pub fn new(
    leader: &'static str,
    continued_leader: &'static str,
    path: Option<PathBuf>
) -> Self
[src]

Create a Repl with specified language interface.

pub fn with_capacity(
    leader: &'static str,
    continued_leader: &'static str,
    capacity: usize,
    path: Option<PathBuf>
) -> Self
[src]

Create a Repl with specified language interface, and specified history capacity.

pub fn set_exit_keyword(&mut self, exit_keyword: &'static str)[src]

Sets the exit keyword. If you don't want any exit keyword, set it to an empty string

pub fn set_clear_keyword(&mut self, clear_keyword: &'static str)[src]

Sets the clear keyword. If you don't want any clear keyword, set it to an empty string

pub fn next(&mut self, colour: Color) -> Result<String>[src]

The main function, gives the next command

Trait Implementations

impl<L: LangInterface> Drop for Repl<L>[src]

Auto Trait Implementations

impl<L = DefaultLangInterface> !RefUnwindSafe for Repl<L>[src]

impl<L> Send for Repl<L> where
    L: Send
[src]

impl<L = DefaultLangInterface> !Sync for Repl<L>[src]

impl<L> Unpin for Repl<L> where
    L: Unpin
[src]

impl<L> UnwindSafe for Repl<L> where
    L: UnwindSafe
[src]

Blanket Implementations

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

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

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

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

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

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.

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.