Struct codespan_reporting::ColorArg
[−]
[src]
pub struct ColorArg(pub ColorChoice);
A command line argument that configures the coloring of the output
This can be used with command line argument parsers like clap
or structopt
.
Example
extern crate codespan_reporting; #[macro_use] extern crate structopt; use structopt::StructOpt; use codespan_reporting::termcolor::StandardStream; use codespan_reporting::ColorArg; #[derive(Debug, StructOpt)] #[structopt(name = "groovey-app")] pub struct Opts { /// Configure coloring of output #[structopt( long = "color", parse(try_from_str), default_value = "auto", raw(possible_values = "ColorArg::VARIANTS", case_insensitive = "true") )] pub color: ColorArg, } fn main() { let opts = Opts::from_args(); let writer = StandardStream::stderr(opts.color.into()); }
Methods
impl ColorArg
[src]
pub const VARIANTS: &'static [&'static str]
VARIANTS: &'static [&'static str] = &["auto", "always", "ansi", "never"]
Allowed values the argument
This is useful for generating documentation via clap
or structopt
's
possible_values
configuration.
Trait Implementations
impl Copy for ColorArg
[src]
impl Clone for ColorArg
[src]
fn clone(&self) -> ColorArg
[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 Debug for ColorArg
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl PartialEq for ColorArg
[src]
fn eq(&self, __arg_0: &ColorArg) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ColorArg) -> bool
[src]
This method tests for !=
.
impl Eq for ColorArg
[src]
impl FromStr for ColorArg
[src]
type Err = &'static str
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<ColorArg, &'static str>
[src]
Parses a string s
to return a value of this type. Read more
impl Into<ColorChoice> for ColorArg
[src]
fn into(self) -> ColorChoice
[src]
Performs the conversion.