5 stable releases

1.0.4 May 2, 2024
1.0.3 Sep 28, 2023
1.0.2 Aug 23, 2023
1.0.1 Jun 20, 2023
1.0.0 Apr 13, 2023

#886 in Command-line interface

Download history 1690/week @ 2024-01-22 2490/week @ 2024-01-29 3120/week @ 2024-02-05 2984/week @ 2024-02-12 1599/week @ 2024-02-19 2624/week @ 2024-02-26 2702/week @ 2024-03-04 2252/week @ 2024-03-11 5416/week @ 2024-03-18 5768/week @ 2024-03-25 5875/week @ 2024-04-01 4866/week @ 2024-04-08 3934/week @ 2024-04-15 4773/week @ 2024-04-22 5227/week @ 2024-04-29 4974/week @ 2024-05-06

19,363 downloads per month
Used in 6 crates

MIT/Apache

17KB
128 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.4–9.5MB
~79K SLoC