[][src]Struct shrust::Shell

pub struct Shell<T> { /* fields omitted */ }

A shell

Methods

impl<T> Shell<T>[src]

pub fn new(data: T) -> Shell<T>[src]

Create a new shell, wrapping data, using provided IO

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

Get a mutable pointer to the inner data

pub fn set_prompt(&mut self, prompt: String)[src]

Change the current prompt

pub fn set_unclosed_prompt(&mut self, prompt: String)[src]

Change the current unclosed prompt

pub fn set_default<F>(&mut self, func: F) where
    F: Fn(&mut ShellIO, &mut Shell<T>, &str) -> ExecResult + Send + Sync + 'static, 
[src]

pub fn new_shell_command<S, F>(
    &mut self,
    name: S,
    description: S,
    nargs: usize,
    func: F
) where
    S: ToString,
    F: Fn(&mut ShellIO, &mut Shell<T>, &[&str]) -> ExecResult + Send + Sync + 'static, 
[src]

Register a shell command. Shell commands get called with a reference to the current shell

pub fn new_command<S, F>(
    &mut self,
    name: S,
    description: S,
    nargs: usize,
    func: F
) where
    S: ToString,
    F: Fn(&mut ShellIO, &mut T, &[&str]) -> ExecResult + Send + Sync + 'static, 
[src]

Register a command

pub fn new_command_noargs<S, F>(&mut self, name: S, description: S, func: F) where
    S: ToString,
    F: Fn(&mut ShellIO, &mut T) -> ExecResult + Send + Sync + 'static, 
[src]

Register a command that do not accept any argument

pub fn print_help(&self, io: &mut ShellIO) -> ExecResult[src]

Print the help to stdout

pub fn get_history(&self) -> &History[src]

Return the command history

pub fn eval(&mut self, io: &mut ShellIO, line: &str) -> ExecResult[src]

Evaluate a command line

pub fn run_loop(&mut self, io: &mut ShellIO)[src]

Enter the shell main loop, exiting only when the "quit" command is called

Trait Implementations

impl<T> Clone for Shell<T> where
    T: Clone
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> DerefMut for Shell<T>[src]

impl<T> Deref for Shell<T>[src]

type Target = T

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> Send for Shell<T> where
    T: Send

impl<T> Unpin for Shell<T> where
    T: Unpin

impl<T> Sync for Shell<T> where
    T: Sync

impl<T> !RefUnwindSafe for Shell<T>

impl<T> !UnwindSafe for Shell<T>

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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