Skip to main content

App

Struct App 

Source
pub struct App<C> { /* private fields */ }
Expand description

One ctl process: short-circuits, help, parsing, execution, and presentation.

Implementations§

Source§

impl<C> App<C>

Source

pub fn new(bin: impl Into<String>) -> Self

Build a CLI with pretty automatic-color output.

Source

pub fn view(self, select: impl Fn(&C) -> View + 'static) -> Self

Select output, color, and quiet policy from the parsed CLI.

Source

pub fn before_parse( self, hook: impl Fn(&[OsString]) -> Option<ExitCode> + 'static, ) -> Self

Add an ordered pre-parse short-circuit, such as dynamic completion.

Source

pub fn mounted_as(self, task: impl Into<String>) -> Self

Expose a mise Usage spec under a mounted task name.

Source

pub fn usage_spec( self, render: impl Fn(Command, &str) -> String + 'static, ) -> Self

Customize the mounted Usage document while keeping App’s short-circuit and stream ownership. The callback receives the declared Clap graph and the requested mounted binary name.

Source§

impl<C> App<C>

Source

pub fn run<T>(self, execute: impl FnOnce(C) -> Result<T>) -> ExitCode
where T: Present,

Run against process argv.

Source

pub fn run_from<T>( self, args: impl IntoIterator<Item = impl Into<OsString>>, execute: impl FnOnce(C) -> Result<T>, ) -> ExitCode
where T: Present,

Run against explicit argv. The first item is the binary name.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for App<C>

§

impl<C> !Send for App<C>

§

impl<C> !Sync for App<C>

§

impl<C> !UnwindSafe for App<C>

§

impl<C> Freeze for App<C>
where Box<dyn Fn(&C) -> View>: Freeze, PhantomData<C>: Freeze,

§

impl<C> Unpin for App<C>
where Box<dyn Fn(&C) -> View>: Unpin, PhantomData<C>: Unpin,

§

impl<C> UnsafeUnpin for App<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.