Struct shi::shell::Shell [−][src]
pub struct Shell<'a, S> { /* fields omitted */ }
Expand description
The shell.
This gives the shell interface for shi. It is constructed and registered with commands. Execution is done through a run-loop of input/output.
Implementations
Constructs a new shell, with the given prompt & state.
Arguments
prompt
- The prompt to display to the user.
state
- The state that the Shell
should persist across command invocations.
Sets the history file & loads the history from it, if it exists already.
This is necessary to call if one wishes for their command history to persist across sessions.
Arguments
history-file
- The path to the history file.
Saves the history.
This is effectively a no-op if no history file has been set.
This must also be called to actually persist the current session’s history. It is necessary to persist the history if one wishes to see it in future sessions.
Eval executes a single loop of the shell’s run-loop.
In other words, it takes a single input line and executes on it; run()
is a loop over
eval()
.
Arguments
line
- The line to evaluate.
Executes the shell’s run-loop.
This will run indefinitely until the user exits, otherwise terminates the shell or process or the shell encounters an error and stops.
Note that invalid command invocations, e.g., nonexistent commands, are not considered fatal errors and do not cause a return from this method.