[][src]Struct combu::command::Command

pub struct Command {
    pub name: String,
    pub action: Option<Action>,
    pub authors: String,
    pub copyright: String,
    pub license: Option<(String, String)>,
    pub description: Option<String>,
    pub usage: String,
    pub l_flags: Vector<Flag>,
    pub c_flags: Vector<Flag>,
    pub alias: Vector<String>,
    pub version: String,
    pub sub: Vector<Command>,
    pub help: Option<HelpFunc>,
}

The struct for command information store and command execution This can be root and edge コマンドの情報格納&実行用構造体

Fields

name: String

Command name

action: Option<Action>

Command action

authors: String

Command authors

copyright: String

Command copyright

license: Option<(String, String)>

license of command

description: Option<String>

Command description

usage: String

Command usage

l_flags: Vector<Flag>

local flags of command

c_flags: Vector<Flag>

common flags of command

alias: Vector<String>

alias for command

version: String

Command version

sub: Vector<Command>

container of sub-command

help: Option<HelpFunc>

custom help fuction

Implementations

impl Command[src]

pub fn new() -> Command[src]

Creare new instance of Command

pub fn with_base<T: Into<String>>(
    name: T,
    authors: T,
    version: T,
    description: T,
    action: Option<Action>
) -> Command
[src]

Create new instance of Command with name,authors,version

pub fn with_name<T: Into<String>>(name: T) -> Command[src]

Create new instance of Command with name

pub fn with_all_field(
    name: String,
    action: Option<Action>,
    authors: String,
    copyright: String,
    license: Option<(String, String)>,
    description: Option<String>,
    usage: String,
    local_flags: Vector<Flag>,
    common_flags: Vector<Flag>,
    alias: Vector<String>,
    version: String,
    sub: Vector<Command>
) -> Command
[src]

Create new instance of Command with more options

pub fn run_with_auto_arg_collect(self) -> Result<ActionResult, ActionError>[src]

Run command with collecting args automatically

pub fn single_run(
    &mut self,
    raw_args: Vec<String>
) -> Result<ActionResult, ActionError>
[src]

Run command as single(do not have sub) command

pub fn show_help(&self, c: &Context)[src]

Show command's help

pub fn default_help<'a>(&self, c: &Context) -> String[src]

Returuns default help as String

pub fn name<T: Into<String>>(self, name: T) -> Command[src]

Set Command's name

pub fn usage<T: Into<String>>(self, usage: T) -> Self[src]

Set command's usage

pub fn action(self, action: Action) -> Self[src]

Set command's action

pub fn authors<T: Into<String>>(self, authors: T) -> Self[src]

Set command's authors

pub fn copyright<T: Into<String>>(self, copyright: T) -> Self[src]

Set command's copyright

pub fn local_flag(self, flag: Flag) -> Self[src]

Add a local flag to command

pub fn common_flag(self, flag: Flag) -> Self[src]

Add a common flag to command

pub fn desctiption<T: Into<String>>(self, description: T) -> Self[src]

Set command's description

pub fn version<T: Into<String>>(self, version: T) -> Self[src]

Set command's version

pub fn sub_command(self, sub_command: Command) -> Self[src]

Add command's sub command

pub fn license(self, license: Option<(String, String)>) -> Self[src]

Sets license

pub fn alias<T: Into<String>>(self, a: T) -> Self[src]

Add command's alias

pub fn help(self, help_function: HelpFunc) -> Self[src]

Set custom help function

pub fn is(&self, name_or_alias: &str) -> bool[src]

Returns true if name_or_alias matches command's name or one of alias at least name_or_aliasがコマンド名かエイリアスのうち少なくとも一つにマッチした場合trueを返す

pub fn take_sub(&mut self, name_or_alias: &str) -> Option<Command>[src]

Take sub command matches name_or_alias. name_or_aliasに一致するサブコマンドがある場合、保持しているVectorからswap_removeで取り出して返す

pub fn get_mut_sub(&mut self, name_or_alias: &str) -> Option<&mut Command>[src]

Gets sub command mutable reference matches name_or_alias.

pub fn has_sub(&self) -> bool[src]

Returns true if this command has sub command(s).

pub fn derive_route_init_vector(&self) -> Vector<String>[src]

Returns init Vector for Context's route

impl Command[src]

pub fn run_from_args(
    &mut self,
    raw_args: Vec<String>
) -> Result<ActionResult, ActionError>
[src]

Run commands with raw_args

pub fn run_with_context(
    &mut self,
    context: Context
) -> Result<ActionResult, ActionError>
[src]

Run command with context

pub fn assign_context(
    &mut self,
    c: Context,
    p: Parser,
    inter_mediate_args: VecDeque<MiddleArg>,
    last: MiddleArg
) -> Result<ActionResult, ActionError>
[src]

Assign context to sub command or command's own action. コンテキストのargsを見てもサブコマンド行きかコマンドでそのまま処理すればいいか分からなかった時の処理用

pub fn assign_run(
    &mut self,
    args: VecDeque<String>,
    inter_mediate_args: VecDeque<MiddleArg>,
    p: Parser,
    raw_args: Vec<String>,
    exe_path: String,
    last: MiddleArg
) -> Result<ActionResult, ActionError>
[src]

Assign subcomannd's run or command's own action with no context コンテキストが生成されていないときに、run_from_args内で第一引数からサブコマンドかそうでないか分からなかった時に再帰処理を行って割り当てを行う関数

pub fn handle_action_result(
    &mut self,
    req: Result<ActionResult, ActionError>
) -> Result<ActionResult, ActionError>
[src]

Handle action's result (Result<ActionResult, ActionError>). Implemented: show help / show help following show error アクションの結果であるResult<ActionResult, ActionError>をハンドルする関数。現在はhelp表示もしくはエラーを表示したのちのヘルプ表示のみ

Trait Implementations

impl Clone for Command[src]

impl Default for Command[src]

impl From<String> for Command[src]

impl Run<Context> for Command[src]

impl Run<Vec<String>> for Command[src]

Auto Trait Implementations

impl RefUnwindSafe for Command

impl Send for Command

impl Sync for Command

impl Unpin for Command

impl UnwindSafe for Command

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.