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]

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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for ColorArg
[src]

[src]

Formats the value using the given formatter. Read more

impl PartialEq for ColorArg
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for ColorArg
[src]

impl FromStr for ColorArg
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl Into<ColorChoice> for ColorArg
[src]

[src]

Performs the conversion.

Auto Trait Implementations

impl Send for ColorArg

impl Sync for ColorArg