6 stable releases

1.0.5 Jul 25, 2024
1.0.4 May 2, 2024
1.0.3 Sep 28, 2023
1.0.2 Aug 23, 2023
1.0.0 Apr 13, 2023

#5 in #clap-parser

Download history 4513/week @ 2024-05-17 4011/week @ 2024-05-24 5519/week @ 2024-05-31 7098/week @ 2024-06-07 5241/week @ 2024-06-14 5620/week @ 2024-06-21 5394/week @ 2024-06-28 5452/week @ 2024-07-05 5067/week @ 2024-07-12 5635/week @ 2024-07-19 5453/week @ 2024-07-26 5386/week @ 2024-08-02 3941/week @ 2024-08-09 4196/week @ 2024-08-16 3554/week @ 2024-08-23 4702/week @ 2024-08-30

17,193 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–2MB
~36K SLoC