pub struct ColorArg(pub ColorChoice);
Expand description
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 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 {
/// 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());
}
Tuple Fields§
§0: ColorChoice
Implementations§
Trait Implementations§
Source§impl Into<ColorChoice> for ColorArg
impl Into<ColorChoice> for ColorArg
Source§fn into(self) -> ColorChoice
fn into(self) -> ColorChoice
Converts this type into the (usually inferred) input type.
impl Copy for ColorArg
impl Eq for ColorArg
impl StructuralPartialEq for ColorArg
Auto Trait Implementations§
impl Freeze for ColorArg
impl RefUnwindSafe for ColorArg
impl Send for ColorArg
impl Sync for ColorArg
impl Unpin for ColorArg
impl UnwindSafe for ColorArg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)