Skip to content

Commit

Permalink
Add color to command help (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 authored Dec 8, 2024
1 parent 54dfbe8 commit f559bf1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use std::ffi::OsString;
use std::path::PathBuf;
use std::process::ExitCode;

use clap::builder::styling::{AnsiColor, Effects};
use clap::builder::Styles;
use clap::{ArgAction, Args, Parser, Subcommand};

use crate::config::{HookType, Stage};
Expand Down Expand Up @@ -75,6 +77,12 @@ impl From<ColorChoice> for anstream::ColorChoice {
}
}

const STYLES: Styles = Styles::styled()
.header(AnsiColor::Green.on_default().effects(Effects::BOLD))
.usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
.literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
.placeholder(AnsiColor::Cyan.on_default());

#[derive(Parser)]
#[command(
name = "prefligit",
Expand All @@ -88,6 +96,7 @@ impl From<ColorChoice> for anstream::ColorChoice {
disable_help_subcommand = true,
disable_version_flag = true
)]
#[command(styles=STYLES)]
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) command: Option<Command>,
Expand Down

0 comments on commit f559bf1

Please sign in to comment.