[][src]Struct xcli::Command

pub struct Command<'a> { /* fields omitted */ }

Command structure, which describes a command and its action.

Implementations

impl<'a> Command<'a>[src]

pub fn new<S: Into<String>>(n: S) -> Self[src]

Create a command

pub fn new_with_alias<S: Into<String>>(n: S, s: S) -> Self[src]

pub fn get_name(&self) -> &str[src]

Get the name of this command.

pub fn get_alias(&self) -> &Option<String>[src]

Get the alias name of this command.

pub fn action(
    mut self: Self,
    action: fn(_: &App<'_>, _: &[&str]) -> XcliResult
) -> Self
[src]

Set a CmdAction to this command.

pub fn about<S: Into<&'a str>>(mut self: Self, about: S) -> Self[src]

Set a description to this command.

pub fn usage<S: Into<&'a str>>(mut self: Self, about: S) -> Self[src]

Set the usage to this command.

pub fn get_subcommands(&self) -> &[Command<'a>][src]

Get all subcommands of this command

pub fn subcommand(mut self: Self, subcmd: Command<'a>) -> Self[src]

Add a subcommand to this command

pub fn subcommands<I>(mut self: Self, subcmds: I) -> Self where
    I: IntoIterator<Item = Command<'a>>, 
[src]

Add more than one subcommand to this command, the given subcmds implements IntoIterator

pub fn show_command_usage(&self)[src]

show usage message for command.

pub fn show_command_help(&self)[src]

show help message for command.

pub fn show_subcommand_help(&self)[src]

show help message for command and its subs

pub fn locate_subcommand(&self, args: &[&str]) -> Option<&Command<'_>>[src]

locate the sub command by the args given

pub fn run_sub(&self, app: &App<'_>, args: &[&str]) -> XcliResult[src]

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

pub fn for_each<F>(&self, path: &str, f: &mut F) where
    F: FnMut(&Self, &str), 
[src]

Trait Implementations

impl<'a> Default for Command<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Command<'a>[src]

impl<'a> Send for Command<'a>[src]

impl<'a> Sync for Command<'a>[src]

impl<'a> Unpin for Command<'a>[src]

impl<'a> UnwindSafe for Command<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.