FJ-28: Colorize clap --help and error output with fj's palette #33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/colorize-clap-help-FJ-28"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Resolves FJ-28: colorize clap's
--helpand error output using fj's existing palette.fj --help(and everyfj <area> --help) previously rendered monochrome because the rootAppcommand never set a clapStyles. This wires aHELP_STYLESconstant that mirrors fj's ownSpecialRender::fancy()colours and attaches it toAppvia#[command(styles = ...)].Changes
crates/fj/src/main.rs: addHELP_STYLES(built fromclap::builder::styling, which re-exports anstyle, so no new dependency) and#[command(styles = HELP_STYLES)]onApp.Palette mapping (from
SpecialRender::fancy()):header/usage: bold cyanliteral(flags, subcommands): greenplaceholder(<COMMAND>,<HOST>): unstylederror: bold red;invalid: red;valid: greenclap keeps the default
ColorChoice::Auto, so color is emitted only on a TTY and is suppressed when piped or whenNO_COLORis set. The root command'sstylespropagate to every subcommand's help automatically.Verification
cargo build -p forgejo-cli,cargo fmt --check,cargo clippy -p forgejo-cli: all pass.TERM=xterm-256colorTTYfj --help: section headers bold cyan, flags/commands green,<COMMAND>placeholder unstyled.fj repo --help(subcommand) is colored the same way (styles propagate).fj --notaflagerror output uses bold rederror:styling.fj --help | catandNO_COLOR=1 fj --helpemit zero ANSI escapes.Acceptance criteria
fj --helpon a TTY colors section headers (bold cyan), flags/commands (green); placeholders unstyled.fj <area> --help(e.g.fj repo --help) is colored the same way.fj --help | catandNO_COLOR=1 fj --helpemit no ANSI escapes.cargo build,cargo fmt --check,cargo clippypass.