Struct ap::App[][src]

pub struct App<'a> { /* fields omitted */ }
Expand description

The main object used to represent the program.

All consumers of the crate need to create a single object of this type.

Implementations

impl<'a> App<'a>[src]

pub fn new(name: &str) -> Self[src]

Create a new application object.

pub fn args(self, args: Args) -> Self[src]

Specify a set of argument handlers to parse the command-line with.

pub fn version(self, version: &str) -> Self[src]

Specify the version of the program.

pub fn summary(self, summary: &str) -> Self[src]

Specify brief explanatory text for the program.

pub fn help(self, help: &str) -> Self[src]

Specify extended usage information for the program.

pub fn notes(self, notes: &str) -> Self[src]

Specify notes for the program.

pub fn settings(self, settings: Settings) -> Self[src]

Specify any settings for the program.

pub fn ignore_unknown_options(self) -> Self[src]

If set, don’t error if unknown options are specified - just ignore them.

Note

This is an alternative to calling the settings() method.

pub fn ignore_unknown_posn_args(self) -> Self[src]

If set, don’t error if unknown positional arguments are specified - just ignore them.

Note

This is an alternative to calling the settings() method.

pub fn no_strict_options(self) -> Self[src]

If set, disallow option values from starting with as dash.

See the Settings method of the same name for full details and an example showing the effect of this call.

Note

This is an alternative to calling the settings() method.

pub fn generate_help<W>(&self, writer: &mut W) -> Result<()> where
    W: Write + Send + Sync + 'static, 
[src]

Generate a help/usage statement from the registered Arg’s.

This is called automatically when the user specifies -h anywhere on the command line; you do not need to register an Arg for -h.

pub fn parse_with_args(&mut self, cli_args: Vec<String>) -> Result<()>[src]

Parse a set of command line arguments (without the program name).

Arguments

  • cli_args: Vector of string arguments. Specify your own, or call get_args().

Notes

  • The cli_args vector must not specify the command name (which by default is returned as the first element by env::args().collect() for example. Use get_args() as this handles this for you.

pub fn handler(self, boxed_handler: Box<dyn Handler + 'a>) -> Self[src]

Specify the handler for the option which must implement the Handler trait.

Note

If the handler needs to modify its own state when called, the specified boxed trait must provide a mutable reference.

pub fn parse(&mut self) -> Result<()>[src]

Simplest interface to the parser.

Trait Implementations

impl<'a> Clone for App<'a>[src]

fn clone(&self) -> App<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for App<'a>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a> Default for App<'a>[src]

fn default() -> App<'a>[src]

Returns the “default value” for a type. Read more

impl<'a> PartialEq<App<'a>> for App<'a>[src]

fn eq(&self, other: &App<'a>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &App<'a>) -> bool[src]

This method tests for !=.

impl<'a> StructuralPartialEq for App<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for App<'a>

impl<'a> !Send for App<'a>

impl<'a> !Sync for App<'a>

impl<'a> Unpin for App<'a>

impl<'a> !UnwindSafe for App<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.