clap-themes 0.1.3

Theme presets for clap CLIs
Documentation
//! `clap_themes` is a quick and easy way to add color and style to your
//! clap-powered CLI!
//!
//! ## Examples
//!
//! ```
//! use clap::Parser;
//!
//! #[derive(Parser)]
//! #[clap(styles = clap_themes::CARGO)]
//! struct Cli {
//!     /// Here's some good help text!
//!     #[clap(short, long)]
//!     arg1: String,
//! }
//! ```

use clap::builder::{
    styling::{Ansi256Color, AnsiColor},
    Styles,
};

pub use doom_one::DOOM_ONE;

/// Colored output in the style of clap v3, before they removed color.
pub const CLAP_V3: Styles = Styles::styled()
    .header(AnsiColor::Yellow.on_default())
    .usage(AnsiColor::Yellow.on_default())
    .placeholder(Ansi256Color(117).on_default())
    .literal(AnsiColor::Green.on_default());

/// Colored output in the style of the cargo command.
pub const CARGO: Styles = Styles::styled()
    .header(AnsiColor::BrightGreen.on_default().bold())
    .usage(AnsiColor::Yellow.on_default())
    .placeholder(AnsiColor::Cyan.on_default())
    .literal(AnsiColor::BrightCyan.on_default().bold());

mod doom_one {
    use clap::builder::{styling::RgbColor, Styles};

    const RED: RgbColor = RgbColor(0xff, 0x6c, 0x6b);
    const _DARK_BLUE: RgbColor = RgbColor(0x22, 0x57, 0xA0);
    const _VIOLET: RgbColor = RgbColor(0xa9, 0xa1, 0xe1);
    const _ORANGE: RgbColor = RgbColor(0xda, 0x85, 0x48);
    const YELLOW: RgbColor = RgbColor(0xec, 0xbe, 0x7b);
    const GREEN: RgbColor = RgbColor(0x98, 0xbe, 0x65);
    const MAGENTA: RgbColor = RgbColor(0xc6, 0x78, 0xdd);

    /// Colored output in the style of the "doom one" ViM theme.
    pub const DOOM_ONE: Styles = Styles::styled()
        .header(YELLOW.on_default().underline())
        .usage(YELLOW.on_default())
        .placeholder(GREEN.on_default())
        .error(RED.on_default())
        .literal(MAGENTA.on_default());
}