pub struct Command {
pub name: String,
pub alias: String,
pub description: String,
pub options: Vec<Flag>,
pub callback: fn(_: &Command, _: &Vec<String>),
}Expand description
The structure of a command in the program
Fields§
§name: StringThe name of the command i.e up, start, run
alias: StringAny alias given to the command, normally a single letter, u, i, s
description: StringA simple description of the command, gets output when the –help flag is passed
options: Vec<Flag>Options are the flags that can be passed to the specified command i.e -q –priority
callback: fn(_: &Command, _: &Vec<String>)Implementations§
Source§impl Command
impl Command
Methods for command mutation
Sourcepub fn command(&mut self, name: &str) -> &mut Command
pub fn command(&mut self, name: &str) -> &mut Command
Changes the name of a command to the passed value
Sourcepub fn alias(&mut self, val: &str) -> &mut Command
pub fn alias(&mut self, val: &str) -> &mut Command
Mutates the alias of the command to which it is attached
Sourcepub fn describe(&mut self, desc: &str) -> &mut Command
pub fn describe(&mut self, desc: &str) -> &mut Command
Edits the description of a command, setting it to the passed value
Sourcepub fn option(&mut self, body: &str) -> &mut Command
pub fn option(&mut self, body: &str) -> &mut Command
Pushes new options to the options vector of a command
pub fn build(&mut self, prog: &mut Program)
pub fn action(&mut self, cb: fn(_: &Command, _: &Vec<String>)) -> &mut Command
pub fn parse()
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more