Struct shrust::Shell
[−]
[src]
pub struct Shell<T> { /* fields omitted */ }
A shell
Methods
impl<T> Shell<T>
[src]
fn new(data: T) -> Shell<T>
Create a new shell, wrapping data
, using provided IO
fn data(&mut self) -> &mut T
Get a mutable pointer to the inner data
fn set_prompt(&mut self, prompt: String)
Change the current prompt
fn set_unclosed_prompt(&mut self, prompt: String)
Change the current unclosed prompt
fn set_default<F>(&mut self, func: F) where
F: Fn(&mut ShellIO, &mut Shell<T>, &str) -> ExecResult + Send + Sync + 'static,
F: Fn(&mut ShellIO, &mut Shell<T>, &str) -> ExecResult + Send + Sync + 'static,
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,
&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,
Register a shell command. Shell commands get called with a reference to the current shell
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,
S: ToString,
F: Fn(&mut ShellIO, &mut T, &[&str]) -> ExecResult + Send + Sync + 'static,
Register a command
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,
S: ToString,
F: Fn(&mut ShellIO, &mut T) -> ExecResult + Send + Sync + 'static,
Register a command that do not accept any argument
fn print_help(&self, io: &mut ShellIO) -> ExecResult
Print the help to stdout
fn get_history(&self) -> &History
Return the command history
fn eval(&mut self, io: &mut ShellIO, line: &str) -> ExecResult
Evaluate a command line
fn run_loop(&mut self, io: &mut ShellIO)
Enter the shell main loop, exiting only when the "quit" command is called
Trait Implementations
impl<T> Deref for Shell<T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T> DerefMut for Shell<T>
[src]
fn deref_mut(&mut self) -> &mut T
The method called to mutably dereference a value
impl<T> Clone for Shell<T> where
T: Clone,
[src]
T: Clone,
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more