[−][src]Struct cmd_parser::CommandParser
Implementations
impl CommandParser
[src]
pub fn new() -> Self
[src]
pub fn insert(
&mut self,
name: &str,
cmd: fn(_: Vec<&str>)
) -> Result<(), &'static str>
[src]
&mut self,
name: &str,
cmd: fn(_: Vec<&str>)
) -> Result<(), &'static str>
Adds a function to the system.
Example
fn echo(args: Vec<&str>) { println!("{}", args[1..].concat()); } let mut parser = cmd_parser::CommandParser::new(); parser.insert("echo", echo);
pub fn call(&mut self, cmd: &str) -> Result<(), &'static str>
[src]
Calls a function with a command string.
Example
let mut parser = cmd_parser::CommandParser::new(); parser.insert("echo", |x| println!("{}", x[1..].concat())); parser.call("echo This is an example!");
pub fn call_args(&mut self, cmd: Vec<&str>) -> Result<(), &'static str>
[src]
Calls a function with an array of components of the command.
Example
let mut parser = cmd_parser::CommandParser::new(); parser.insert("echo", |x| println!("{}", x[1..].concat())); parser.call_args(vec!["echo", "This is an example"]);
Auto Trait Implementations
impl RefUnwindSafe for CommandParser
impl Send for CommandParser
impl Sync for CommandParser
impl Unpin for CommandParser
impl UnwindSafe for CommandParser
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>,