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

#1079 in Command-line interface

Download history 5952/week @ 2024-07-25 5439/week @ 2024-08-01 4214/week @ 2024-08-08 4009/week @ 2024-08-15 3759/week @ 2024-08-22 5243/week @ 2024-08-29 4588/week @ 2024-09-05 5138/week @ 2024-09-12 5195/week @ 2024-09-19 4955/week @ 2024-09-26 4409/week @ 2024-10-03 5523/week @ 2024-10-10 5878/week @ 2024-10-17 6418/week @ 2024-10-24 4963/week @ 2024-10-31 3745/week @ 2024-11-07

21,782 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