[][src]Struct seahorse::App

pub struct App {
    pub name: String,
    pub author: String,
    pub description: Option<String>,
    pub usage: String,
    pub version: 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: String

Application author

description: Option<String>

Application description

usage: String

Application usage

version: String

Application version

commands: Option<Vec<Command>>

Application commands

action: Option<Action>

Application action

flags: Option<Vec<Flag>>

Application flags

Methods

impl App[src]

pub fn new() -> Self[src]

Create new instance of App

Example

use seahorse::App;

let app = App::new();

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

Set name of the app

Example

use seahorse::App;

let app = App::new()
    .name("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()
    .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()
    .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();
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();
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()
    .name("hello")
    .usage("cli hello [arg]")
    .action(|c| println!("{:?}", c.args));

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

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()
    .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()
    .flag(Flag::new("bool", "cli [arg] --bool", FlagType::Bool))
    .flag(Flag::new("int", "cli [arg] --int [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();
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.