A command line argument that configures the coloring of the output
This can be used with command line argument parsers like clap
or structopt
.
extern crate language_reporting;
#[macro_use]
extern crate structopt;
use structopt::StructOpt;
use termcolor::StandardStream;
use language_reporting::ColorArg;
#[derive(Debug, StructOpt)]
#[structopt(name = "groovey-app")]
pub struct Opts {
#[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());
}
Allowed values the argument
This is useful for generating documentation via clap
or structopt
's
possible_values
configuration.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
type Err = &'static str
The associated error which can be returned from parsing.
Parses a string s
to return a value of this type. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static