#clap #cli #color #terminal #ansi

colorchoice-clap

Clap mixin to override console colors

4 stable releases

new 1.0.3 Sep 28, 2023
1.0.2 Aug 23, 2023
1.0.1 Jun 20, 2023
1.0.0 Apr 13, 2023

#7 in #cli-color

Download history 2030/week @ 2023-06-09 2297/week @ 2023-06-16 1272/week @ 2023-06-23 1260/week @ 2023-06-30 1211/week @ 2023-07-07 1437/week @ 2023-07-14 2733/week @ 2023-07-21 2863/week @ 2023-07-28 2466/week @ 2023-08-04 2228/week @ 2023-08-11 2679/week @ 2023-08-18 2672/week @ 2023-08-25 2474/week @ 2023-09-01 1781/week @ 2023-09-08 1968/week @ 2023-09-15 1957/week @ 2023-09-22

8,411 downloads per month
Used in 7 crates

MIT/Apache

14KB
118 lines

colorchoice-clap

Convenience helper for working with clap to override console colors

Documentation License Crates Status

Contribute

License

Dual-licensed under MIT or Apache 2.0


lib.rs:

Mixin a clap argument for colored output selection

Examples

To get --color through your entire program, just flatten Color and use it to configure your formatter:

use clap::Parser;
use owo_colors::OwoColorize as _;

/// Le CLI
#[derive(Debug, Parser)]
struct Cli {
    #[command(flatten)]
    color: colorchoice_clap::Color,
}

let cli = Cli::parse();

cli.color.write_global();

anstream::println!("Hello, {}!", "world".red());

Dependencies

~1.5–2MB
~38K SLoC