7 stable releases

1.0.6 Oct 24, 2024
1.0.5 Jul 25, 2024
1.0.4 May 2, 2024
1.0.3 Sep 28, 2023
1.0.0 Apr 13, 2023

#1106 in Command-line interface

Download history 5149/week @ 2024-09-22 4433/week @ 2024-09-29 5244/week @ 2024-10-06 5382/week @ 2024-10-13 6540/week @ 2024-10-20 5830/week @ 2024-10-27 4596/week @ 2024-11-03 4521/week @ 2024-11-10 4642/week @ 2024-11-17 4969/week @ 2024-11-24 4681/week @ 2024-12-01 4404/week @ 2024-12-08 4551/week @ 2024-12-15 2538/week @ 2024-12-22 3970/week @ 2024-12-29 4287/week @ 2025-01-05

15,614 downloads per month
Used in 11 crates

MIT/Apache

18KB
126 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.3–1.9MB
~35K SLoC