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§
sourceconst REQUIRES_INPUT: bool
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§
sourcefn parse_internal(key: &str, args: &mut Vec<OsString>) -> Result<Self, Error>
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.
sourcefn tiny_help_message(key: &str) -> String
fn tiny_help_message(key: &str) -> String
Return a tiny help message.
Provided Methods§
sourcefn from_args() -> Self
fn from_args() -> Self
Parse the command-line arguments, exiting in case of error.
This is what users actually use.
sourcefn parse_vec(args: Vec<OsString>) -> Result<Self, Error>
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.
sourcefn from_iter<I, T>(args: I) -> Result<Self, Error>where
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
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.
sourcefn help_message(key: &str, doc: &str) -> String
fn help_message(key: &str, doc: &str) -> String
Return a help message.