Trait abscissa_core::Options [−][src]
Implements a set of options parsed from command line arguments.
An implementation of this trait can be generated with #[derive(Options)]
.
Required methods
pub fn parse<S>(parser: &mut Parser<'_, S>) -> Result<Self, Error> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Parses arguments until the given parser is exhausted or until an error is encountered.
pub fn parse_command<S>(
name: &str,
parser: &mut Parser<'_, S>
) -> Result<Self, Error> where
S: AsRef<str>,
[src]
name: &str,
parser: &mut Parser<'_, S>
) -> Result<Self, Error> where
S: AsRef<str>,
Parses options for the named command.
pub fn usage() -> &'static str
[src]
Returns a string showing usage and help for each supported option.
Option descriptions are separated by newlines. The returned string should not end with a newline.
pub fn command_usage(command: &str) -> Option<&'static str>
[src]
Returns a usage string for the named command.
If the named command does not exist, None
is returned.
Command descriptions are separated by newlines. The returned string should not end with a newline.
pub fn command_list() -> Option<&'static str>
[src]
Returns a string listing available commands and help text.
Commands are separated by newlines. The string should not end with a newline.
For enum
types with derive(Options)
, this is the same as usage
.
For struct
types containing a field marked #[options(command)]
,
usage
is called on the command type.
Provided methods
pub fn command_name(&self) -> Option<&'static str>
[src]
Returns the name of a parsed command, if present.
This is implemented by derive(Options)
in one of two ways:
- For
struct
types, if the type contains a field marked#[options(command)]
, this method is called on that value. Otherwise,None
is returned. - For
enum
types, the name corresponding to the variant is returned.
pub fn help_requested(&self) -> bool
[src]
Returns whether the user supplied a "help" option to request usage information about the program or any contained subcommands.
The default implementation returns false
.
pub fn parse_args<S>(args: &[S], style: ParsingStyle) -> Result<Self, Error> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Parses arguments received from the command line.
The first argument (the program name) should be omitted.
pub fn parse_args_or_exit(style: ParsingStyle) -> Self
[src]
Parses arguments from the environment.
If an error is encountered, the error is printed to stderr
and the
process will exit with status code 2
.
If the user supplies a help option, option usage will be printed to
stdout
and the process will exit with status code 0
.
Otherwise, the parsed options are returned.
pub fn parse_args_default_or_exit() -> Self
[src]
Parses arguments from the environment, using the default parsing style.
If an error is encountered, the error is printed to stderr
and the
process will exit with status code 2
.
If the user supplies a help option, option usage will be printed to
stdout
and the process will exit with status code 0
.
Otherwise, the parsed options are returned.
pub fn parse_args_default<S>(args: &[S]) -> Result<Self, Error> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Parses arguments received from the command line, using the default parsing style.
The first argument (the program name) should be omitted.
Implementors
impl<C> Options for Help<C> where
C: Command,
[src]
C: Command,
fn parse<S: AsRef<str>>(parser: &mut Parser<'_, S>) -> Result<Self, Error>
[src]
fn parse_command<S: AsRef<str>>(
_name: &str,
parser: &mut Parser<'_, S>
) -> Result<Self, Error>
[src]
_name: &str,
parser: &mut Parser<'_, S>
) -> Result<Self, Error>
fn usage() -> &'static str
[src]
fn command_usage(_command: &str) -> Option<&'static str>
[src]
fn command_list() -> Option<&'static str>
[src]
impl<Cmd> Options for EntryPoint<Cmd> where
Cmd: Command + Runnable,
[src]
Cmd: Command + Runnable,
fn parse<__S: AsRef<str>>(_parser: &mut Parser<'_, __S>) -> Result<Self, Error>
[src]
fn command_name(&self) -> Option<&'static str>
[src]
fn help_requested(&self) -> bool
[src]
fn parse_command<__S: AsRef<str>>(
name: &str,
_parser: &mut Parser<'_, __S>
) -> Result<Self, Error>
[src]
name: &str,
_parser: &mut Parser<'_, __S>
) -> Result<Self, Error>