Struct shi::command::basic::BasicCommand [−][src]
A BasicCommand is a very simple command type. It has a name, and it has a closure that it executes when it is invoked. The closure takes a state, as determined by its containing shell, and a vector of String arguments.
Implementations
impl<'a, S> BasicCommand<'a, S>
[src]
pub fn new<F>(name: &'a str, exec: F) -> BasicCommand<'a, S> where
F: Fn(&mut S, &[String]) -> Result<String> + 'static,
[src]
F: Fn(&mut S, &[String]) -> Result<String> + 'static,
Creates a new BasicCommand with the given name and closure.
Arguments
name
- The name of the command. This is how users will execute the command.exec
- The closure that will be executed when this command is invoked.
pub fn new_with_help<F>(
name: &'a str,
help: &'a str,
exec: F
) -> BasicCommand<'a, S> where
F: Fn(&mut S, &[String]) -> Result<String> + 'static,
[src]
name: &'a str,
help: &'a str,
exec: F
) -> BasicCommand<'a, S> where
F: Fn(&mut S, &[String]) -> Result<String> + 'static,
Creates a new BasicCommand with the given name, closure and help message.
Arguments
name
- The name of the command. This is how users will execute the command.exec
- The closure that will be executed when this command is invoked.help
- The help message to use.
Trait Implementations
impl<'a, S> BaseCommand for BasicCommand<'a, S>
[src]
type State = S
The State of the command. Expected to be bound to a containing Shell
.
fn name(&self) -> &str
[src]
fn validate_args(&self, _: &[String]) -> Result<()>
[src]
fn execute(&self, state: &mut S, args: &[String]) -> Result<String>
[src]
fn help(&self) -> String
[src]
fn autocomplete(&self, _args: Vec<&str>, _trailing_space: bool) -> Completion
[src]
Auto Trait Implementations
impl<'a, S> !RefUnwindSafe for BasicCommand<'a, S>
impl<'a, S> !Send for BasicCommand<'a, S>
impl<'a, S> !Sync for BasicCommand<'a, S>
impl<'a, S> Unpin for BasicCommand<'a, S>
impl<'a, S> !UnwindSafe for BasicCommand<'a, S>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,