Expand description
Control color with a --color
flag for your CLI
§Examples
To get --color
through your entire program, just flatten
Color
:
use clap::Parser;
use clap_color_flag::Color;
/// Le CLI
#[derive(Debug, Parser)]
struct Cli {
#[command(flatten)]
color: Color,
}
You can then use this to configure your formatter:
use anstream::println;
use owo_colors::OwoColorize as _;
let cli = Cli::parse();
cli.color.write_global();
println!("Hello, {}!", "world".red());