Struct seahorse::App [−][src]
Multiple action application entry point
Fields
name: String
Application name
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,