Trait auto_args::AutoArgs

source ·
pub trait AutoArgs: Sized {
    const REQUIRES_INPUT: bool;

    // Required methods
    fn parse_internal(
        key: &str,
        args: &mut Vec<OsString>
    ) -> Result<Self, Error>;
    fn tiny_help_message(key: &str) -> String;

    // Provided methods
    fn from_args() -> Self { ... }
    fn parse_vec(args: Vec<OsString>) -> Result<Self, Error> { ... }
    fn from_iter<I, T>(args: I) -> Result<Self, Error>
       where I: IntoIterator<Item = T>,
             T: Into<OsString> + Clone { ... }
    fn help_message(key: &str, doc: &str) -> String { ... }
    fn usage() -> String { ... }
    fn help() -> String { ... }
}
Expand description

The primary trait, which is implemented by any type which may be part of your command-line flags.

Required Associated Constants§

source

const REQUIRES_INPUT: bool

Indicates whether this type requires any input.

This is false if the data may be processed with no input, true otherwise.

Required Methods§

source

fn parse_internal(key: &str, args: &mut Vec<OsString>) -> Result<Self, Error>

For implementation, but not for using this library.

Parse this flag from the arguments, and return the set of remaining arguments if it was successful. Otherwise return an error message indicating what went wrong. The prefix is a string that should be inserted prior to a flag name.

source

fn tiny_help_message(key: &str) -> String

Return a tiny help message.

Provided Methods§

source

fn from_args() -> Self

Parse the command-line arguments, exiting in case of error.

This is what users actually use.

source

fn parse_vec(args: Vec<OsString>) -> Result<Self, Error>

Parse a Vec of arguments as if they were command line flags

This mimics what we would do if we were doing the real parsing, except that we don’t exit on error.

source

fn from_iter<I, T>(args: I) -> Result<Self, Error>where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse arguments given through an iterable thing such as a Vec or a slice, ignoring first element.

source

fn help_message(key: &str, doc: &str) -> String

Return a help message.

source

fn usage() -> String

Usage text for the actual command

source

fn help() -> String

Help text for the actual command

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AutoArgs for bool

source§

impl AutoArgs for f32

source§

impl AutoArgs for f64

source§

impl AutoArgs for i8

source§

impl AutoArgs for i16

source§

impl AutoArgs for i32

source§

impl AutoArgs for i64

source§

impl AutoArgs for isize

source§

impl AutoArgs for u8

source§

impl AutoArgs for u16

source§

impl AutoArgs for u32

source§

impl AutoArgs for u64

source§

impl AutoArgs for usize

source§

impl AutoArgs for String

source§

impl AutoArgs for Vec<f32>

source§

impl AutoArgs for Vec<f64>

source§

impl AutoArgs for Vec<i8>

source§

impl AutoArgs for Vec<i16>

source§

impl AutoArgs for Vec<i32>

source§

impl AutoArgs for Vec<i64>

source§

impl AutoArgs for Vec<isize>

source§

impl AutoArgs for Vec<u8>

source§

impl AutoArgs for Vec<u16>

source§

impl AutoArgs for Vec<u32>

source§

impl AutoArgs for Vec<u64>

source§

impl AutoArgs for Vec<usize>

source§

impl AutoArgs for Vec<String>

source§

impl AutoArgs for Vec<PathBuf>

source§

impl AutoArgs for PathBuf

source§

impl<T> AutoArgs for PhantomData<T>

source§

const REQUIRES_INPUT: bool = false

source§

fn parse_internal(_key: &str, _args: &mut Vec<OsString>) -> Result<Self, Error>

source§

fn tiny_help_message(_key: &str) -> String

source§

impl<T: AutoArgs> AutoArgs for Option<T>

Implementors§