[][src]Struct codespan_reporting::term::ColorArg

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

use structopt::StructOpt;
use codespan_reporting::term::termcolor::StandardStream;
use codespan_reporting::term::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][src]

Allowed values the argument.

This is useful for generating documentation via clap or structopt's possible_values configuration.

Trait Implementations

impl Into<ColorChoice> for ColorArg[src]

impl Clone for ColorArg[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<ColorArg> for ColorArg[src]

impl Eq for ColorArg[src]

impl Copy for ColorArg[src]

impl Debug for ColorArg[src]

impl FromStr for ColorArg[src]

type Err = &'static str

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Unpin for ColorArg

impl Sync for ColorArg

impl Send for ColorArg

impl UnwindSafe for ColorArg

impl RefUnwindSafe for ColorArg

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]