pub struct Shell<'a, T, M: Display, H, I: InputHandler> {
pub prompt: M,
pub commands: HashMap<&'a str, Command<T>>,
pub state: T,
pub handler: H,
pub description: String,
pub input_handler: I,
}
Expand description
A shell represents a shell for editing commands in.
Here are the generics:
- T: The state.
- M: The prompt. Can be anything that can be printed.
- H: The handler. Should implement either
Handler
orAsyncHandler
, or no functionality is present. - I: The input handler. Must implement
InputHandler
Fields§
§prompt: M
The shell prompt.
It can be anything which implements Display and can therefore be printed (This allows for prompts that change with the state.)
commands: HashMap<&'a str, Command<T>>
This is a list of commands for the shell. The hashmap key is the
name of the command (ie "greet"
) and the value is a wrapper
to the function it corresponds to (as well as help information.)
state: T
This is the state of the shell. This stores any values that you need to be persisted over multiple shell commands. For example it may be a simple counter or maybe a session ID.
handler: H
This is the handler for commands. See the Handler
documentation for more.
description: String
This is the description of the shell as a whole. This is displayed when requesting help information.
input_handler: I
The input method
Implementations§
source§impl<'a, T: Send, M: Display, H: AsyncHandler<T>, I: InputHandler> Shell<'a, T, M, H, I>
impl<'a, T: Send, M: Display, H: AsyncHandler<T>, I: InputHandler> Shell<'a, T, M, H, I>
Trait Implementations§
source§impl<'a, T: Clone, M: Clone + Display, H: Clone, I: Clone + InputHandler> Clone for Shell<'a, T, M, H, I>
impl<'a, T: Clone, M: Clone + Display, H: Clone, I: Clone + InputHandler> Clone for Shell<'a, T, M, H, I>
source§impl<'f: 't, 't, T: Serialize + for<'a> Deserialize<'a>, M: Display, H: Handler<T>, I: InputHandler> TryFrom<Shell<'f, T, M, H, I>> for App<'t, T, DefaultCommandLineHandler>
Available on crate feature app
only.
impl<'f: 't, 't, T: Serialize + for<'a> Deserialize<'a>, M: Display, H: Handler<T>, I: InputHandler> TryFrom<Shell<'f, T, M, H, I>> for App<'t, T, DefaultCommandLineHandler>
app
only.