[][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()
    .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()
    .usage("cli cmd [arg]");

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

Set action of the command

Example

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

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

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

Set flag of the command

Example

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

let command = Command::new()
    .flag(Flag::new("bool", "cli [arg] --bool", FlagType::Bool))
    .flag(Flag::new("int", "cli [arg] --int [int]", FlagType::Int));

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.