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 4740/week @ 2024-09-25 4449/week @ 2024-10-02 5737/week @ 2024-10-09 5627/week @ 2024-10-16 6626/week @ 2024-10-23 4945/week @ 2024-10-30 4655/week @ 2024-11-06 4616/week @ 2024-11-13 5147/week @ 2024-11-20 5096/week @ 2024-11-27 4189/week @ 2024-12-04 3988/week @ 2024-12-11 3948/week @ 2024-12-18 3015/week @ 2024-12-25 4640/week @ 2025-01-01 4492/week @ 2025-01-08

16,785 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