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

#1127 in Command-line interface

Download history 4770/week @ 2024-11-15 4973/week @ 2024-11-22 4756/week @ 2024-11-29 4387/week @ 2024-12-06 4322/week @ 2024-12-13 3004/week @ 2024-12-20 3543/week @ 2024-12-27 4740/week @ 2025-01-03 4460/week @ 2025-01-10 3710/week @ 2025-01-17 3733/week @ 2025-01-24 4729/week @ 2025-01-31 5025/week @ 2025-02-07 5152/week @ 2025-02-14 8493/week @ 2025-02-21 6130/week @ 2025-02-28

25,658 downloads per month
Used in 10 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.2–1.8MB
~34K SLoC