pub struct Command<'a> { /* private fields */ }Expand description
Command structure, which describes a command and its action.
Implementations§
Source§impl<'a> Command<'a>
impl<'a> Command<'a>
pub fn new_with_alias<S: Into<String>>(n: S, s: S) -> Self
Sourcepub fn action(self, action: fn(&App<'_>, &[&str]) -> XcliResult) -> Self
pub fn action(self, action: fn(&App<'_>, &[&str]) -> XcliResult) -> Self
Set a CmdAction to this command.
Sourcepub fn get_subcommands(&self) -> &[Command<'a>]
pub fn get_subcommands(&self) -> &[Command<'a>]
Get all subcommands of this command
Sourcepub fn subcommand(self, subcmd: Command<'a>) -> Self
pub fn subcommand(self, subcmd: Command<'a>) -> Self
Add a subcommand to this command
Sourcepub fn subcommands<I>(self, subcmds: I) -> Selfwhere
I: IntoIterator<Item = Command<'a>>,
pub fn subcommands<I>(self, subcmds: I) -> Selfwhere
I: IntoIterator<Item = Command<'a>>,
Add more than one subcommand to this command, the given subcmds implements IntoIterator
Sourcepub fn show_command_usage(&self)
pub fn show_command_usage(&self)
show usage message for command.
Sourcepub fn show_command_help(&self)
pub fn show_command_help(&self)
show help message for command.
Sourcepub fn show_subcommand_help(&self)
pub fn show_subcommand_help(&self)
show help message for command and its subs
Sourcepub fn locate_subcommand(&self, args: &[&str]) -> Option<&Command<'_>>
pub fn locate_subcommand(&self, args: &[&str]) -> Option<&Command<'_>>
locate the sub command by the args given
Sourcepub fn run_sub(&self, app: &App<'_>, args: &[&str]) -> XcliResult
pub fn run_sub(&self, app: &App<'_>, args: &[&str]) -> XcliResult
run sub commands
show error message when action not found but with extra args
show help messages when action not found for the sub command
execute sub command when action found
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Command<'a>
impl<'a> RefUnwindSafe for Command<'a>
impl<'a> Send for Command<'a>
impl<'a> Sync for Command<'a>
impl<'a> Unpin for Command<'a>
impl<'a> UnwindSafe for Command<'a>
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