[][src]Struct seahorse::Command

pub struct Command {
    pub name: String,
    pub usage: String,
    pub action: Action,
    pub flags: Option<Vec<Flag>>,
}

Application command type

Fields

name: String

Command name

usage: String

Command usage

action: Action

Command action

flags: Option<Vec<Flag>>

Action flags

Methods

impl Command[src]

pub fn new() -> Self[src]

Create new instance of Command

Example

use seahorse::Command;

let command = Command::new();

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

Set name of the command

Example

use seahorse::Command;

let command = Command::new();
command.name("cmd");

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

Set usage of the command

Example

use seahorse::Command;

let command = Command::new();
command.usage("cli cmd [arg]");

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

Set action of the command

Example

use seahorse::{Command, Context, Action};

let command = Command::new();
let action: Action = |c: &Context| println!("{:?}", c.args);
command.action(action);

pub fn flags(self, flags: Vec<Flag>) -> Self[src]

Set flags of the command

Example

use seahorse::{Command, Flag, FlagType};

let command = Command::new();
command.flags(vec![
    Flag::new("bool", "cli cmd [arg] --bool", FlagType::Bool),
    Flag::new("string", "cli cmd [arg] --string [string]", FlagType::String)
]);

pub fn run(&self, v: Vec<String>)[src]

Run command Call this function only from App

Trait Implementations

impl Default 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, 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.