Skip to content

CLI: catch rift help; style grouped help with colors#172

Merged
saltyskip merged 1 commit into
mainfrom
feat/cli-grouped-help-styling
May 26, 2026
Merged

CLI: catch rift help; style grouped help with colors#172
saltyskip merged 1 commit into
mainfrom
feat/cli-grouped-help-styling

Conversation

@saltyskip
Copy link
Copy Markdown
Owner

Two small follow-ups on #171 (the grouped-help renderer).

1. rift help now hits the grouped renderer

clap auto-adds a built-in help subcommand that bypasses our argv-prefix intercept. rift help was still printing the flat clap-default Commands list. Extends the intercept to catch help alongside -h / --help.

rift help <subcommand> still falls through to clap correctly — nested help is what clap handles well.

2. Styling pass via console crate (already a dep)

Before this PR every line was plain text; now there's visual hierarchy:

  • Group headers (Account: / Resources: / Billing: / Meta:): yellow + bold — anchors the eye to the structure.
  • Command names (init, links, subscribe, …): cyan + bold — matches gh / kubectl / fly.
  • Usage: / Options:: bold (no color) — same shape clap uses.
  • Aliases: … hint and footer: dim — context, not action.

console::colors_enabled() gates the entire style block: NO_COLOR, non-TTY stdout, and CI environments all get plain text (verified by piping into cat).

Padding gotcha worth noting

ANSI escape codes inflate String::len(), so right-padding a styled name with "{:<12}" produces visibly broken alignment (the escape bytes count toward the width). The fix is to measure the raw name, build the pad string manually, then emit the styled name with the pad appended. Pulled into a print_row helper since both the group loop and the "Other:" fallback share the same shape.

Test plan

  • cargo fmt --check, cargo clippy -D warnings, cargo test on client/cli
  • rift help produces the grouped renderer output
  • rift, rift -h, rift --help still produce the same output
  • rift --help | cat strips all ANSI (piped → no colors)
  • rift links --help unchanged (clap default, scoped)
  • Post-merge auto-patch publishes the next CLI version. After rift update, visually confirm yellow group headers + cyan command names render in a real terminal.

🤖 Generated with Claude Code

Two follow-ups on the grouped-help renderer:

1. `rift help` was still hitting clap's built-in `help` subcommand,
   which prints the flat clap-default output. Extend the argv-prefix
   intercept to catch `help` alongside `-h` / `--help`. `rift help
   <subcommand>` still falls through to clap (correctly — nested help
   is what clap handles well).

2. Styling pass via the `console` crate (already a dep):
   - Group headers (Account: / Resources: / Billing: / Meta:): yellow,
     bold — pop-out so the grouping is the visual anchor.
   - Command names (init, links, …): cyan, bold — matches the
     convention from gh, kubectl, fly.
   - "Usage:" / "Options:": bold (no color) — clap's default look.
   - "Aliases: …" hint and footer "Run …": dim — they're context,
     not action.

`console::colors_enabled()` gates the entire style block: when stdout
isn't a TTY or `NO_COLOR` is set, every style collapses to plain text
so piped / file / CI output stays clean.

Padding bug avoided: the styled-string `.len()` includes ANSI escape
bytes, so the alignment uses the raw name length and prepends spaces
manually. Pulled the per-row rendering into a `print_row` helper since
both the group loop and the "Other:" fallback do the same thing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rift Ready Ready Preview, Comment May 26, 2026 3:55pm

Request Review

@saltyskip saltyskip merged commit fcbe42a into main May 26, 2026
7 checks passed
@saltyskip saltyskip deleted the feat/cli-grouped-help-styling branch May 26, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant