Add colors to --help (#253)

Thank you!
This commit is contained in:
Filip Czaplicki authored and GitHub committed 2026-02-14 13:08:00 +01:00
1 parent 2e2643782d
commit 7f8db4f113
2 files changed
+10 -1

No files matched your search

+1
View File
@@ -6,6 +6,7 @@
- Add `--color-scheme` option, see #247 (@aticu)
- Add `braille` character table, see #247 (@aticu)
- Add command line argument to generate shell completion, see #155 (@friedz)
- Add colors to `--help`/`-h`, see #253 (@starsep)
## Bugfixes
+9 -1
View File
@@ -3,7 +3,9 @@ use std::io::{self, prelude::*, BufWriter, SeekFrom};
use std::num::{NonZeroI64, NonZeroU64};
use std::path::PathBuf;
use clap::builder::styling::{AnsiColor, Effects};
use clap::builder::ArgPredicate;
use clap::builder::Styles;
use clap::{ArgAction, CommandFactory, Parser, ValueEnum};
use clap_complete::aot::{generate, Shell};
@@ -54,8 +56,14 @@ Since the terminal width may not be an evenly divisible by the width per hex dat
the right.
Cannot be used with other width-setting options.";
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(Debug, Parser)]
#[command(version, about, max_term_width(90))]
#[command(version, about, max_term_width(90), styles = STYLES)]
struct Opt {
/// The file to display. If no FILE argument is given, read from STDIN.
#[arg(value_name("FILE"))]