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>>,
}
Expand description
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
sourceimpl App
impl App
sourcepub fn new<T: Into<String>>(name: T) -> Self
pub fn new<T: Into<String>>(name: T) -> Self
Create new instance of App
Example
use seahorse::App;
let app = App::new("cli");
Set author of the app
Example
use seahorse::App;
let app = App::new("cli")
.author(env!("CARGO_PKG_AUTHORS"));
sourcepub fn description<T: Into<String>>(self, description: T) -> Self
pub fn description<T: Into<String>>(self, description: T) -> Self
Set description of the app
Example
use seahorse::App;
let app = App::new("cli")
.description(env!("CARGO_PKG_DESCRIPTION"));
sourcepub fn usage<T: Into<String>>(self, usage: T) -> Self
pub fn usage<T: Into<String>>(self, usage: T) -> Self
Set usage of the app
Example
use seahorse::App;
let app = App::new("cli");
app.usage("cli [command] [arg]");
sourcepub fn version<T: Into<String>>(self, version: T) -> Self
pub fn version<T: Into<String>>(self, version: T) -> Self
Set version of the app
Example
use seahorse::App;
let app = App::new("cli");
app.version(env!("CARGO_PKG_VERSION"));
sourcepub fn command(self, command: Command) -> Self
pub fn command(self, command: Command) -> Self
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);
sourcepub fn action(self, action: Action) -> Self
pub fn action(self, action: Action) -> Self
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);
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more