Struct seahorse::App[][src]

pub struct App {
    pub name: String,
    pub author: Option<String>,
    pub description: Option<String>,
    pub usage: Option<String>,
    pub version: Option<String>,
    pub commands: Option<Vec<Command>>,
    pub action: Option<Action>,
    pub flags: Option<Vec<Flag>>,
}

Multiple action application entry point

Fields

name: String

Application name

author: Option<String>

Application author

description: Option<String>

Application description

usage: Option<String>

Application usage

version: Option<String>

Application version

commands: Option<Vec<Command>>

Application commands

action: Option<Action>

Application action

flags: Option<Vec<Flag>>

Application flags

Implementations

impl App[src]

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

Create new instance of App

Example

use seahorse::App;

let app = App::new("cli");

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

Set author of the app

Example

use seahorse::App;

let app = App::new("cli")
    .author(env!("CARGO_PKG_AUTHORS"));

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

Set description of the app

Example

use seahorse::App;

let app = App::new("cli")
    .description(env!("CARGO_PKG_DESCRIPTION"));

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

Set usage of the app

Example

use seahorse::App;

let app = App::new("cli");
app.usage("cli [command] [arg]");

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

Set version of the app

Example

use seahorse::App;

let app = App::new("cli");
app.version(env!("CARGO_PKG_VERSION"));

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

Set command of the app

Example

use seahorse::{App, Command};

let command = Command::new("hello")
    .usage("cli hello [arg]")
    .action(|c| println!("{:?}", c.args));

let app = App::new("cli")
    .command(command);

Panics

You cannot set a command named as same as registered ones.

use seahorse::{App, Command};

let command1 = Command::new("hello")
    .usage("cli hello [arg]")
    .action(|c| println!("{:?}", c.args));

let command2 = Command::new("hello")
    .usage("cli hello [arg]")
    .action(|c| println!("{:?}", c.args));

let app = App::new("cli")
    .command(command1)
    .command(command2);

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

Set action of the app

Example

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

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

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

Set flag of the app

Example

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

let app = App::new("cli")
    .flag(Flag::new("bool", FlagType::Bool))
    .flag(Flag::new("int", FlagType::Int));

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

Run app

Example

use std::env;
use seahorse::App;

let args: Vec<String> = env::args().collect();
let app = App::new("cli");
app.run(args);

Trait Implementations

impl Default for App[src]

Auto Trait Implementations

impl RefUnwindSafe for App

impl Send for App

impl Sync for App

impl Unpin for App

impl UnwindSafe for App

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.