pub trait Scope {
fn command(&mut self, line: Line<'_>) -> CommandResult;
fn prompt(&self) -> String { ... }
fn empty(&mut self) -> CommandResult { ... }
fn default(&mut self, _line: Line<'_>) -> CommandResult { ... }
}
Expand description
Trait for implementing a Scope object. This trait can be implemented by a client but will most likely be implemented for you by the cmdr macro.
Required Methods
sourcefn command(&mut self, line: Line<'_>) -> CommandResult
fn command(&mut self, line: Line<'_>) -> CommandResult
Execute a single line
Provided Methods
sourcefn prompt(&self) -> String
fn prompt(&self) -> String
Return the prompt for this scope. The default implementation returns > as a prompt but thus can be overridden to return other strings or implement dynamically generated prompts
sourcefn empty(&mut self) -> CommandResult
fn empty(&mut self) -> CommandResult
Execute an empty line. The default implentation does nothing but this can be overridden by a client-application to implement other behaviour
sourcefn default(&mut self, _line: Line<'_>) -> CommandResult
fn default(&mut self, _line: Line<'_>) -> CommandResult
A user entered an unknown command. The default implementation prints an error to the user and returns ok to go on. Can be overridden by a client-application to implement other behaviour