Skip to content

fix(docs): strip authored ANSI from plain help - #1357

Merged
jdx merged 2 commits into
mainfrom
fix/help-plain-strip-ansi
Sep 1, 2026
Merged

fix(docs): strip authored ANSI from plain help#1357
jdx merged 2 commits into
mainfrom
fix/help-plain-strip-ansi

Conversation

@jdx

@jdx jdx commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • make Style::PLAIN remove ANSI CSI sequences already embedded in authored help
  • keep the usage-argv and usage-lib renderers in parity without adding argv dependencies
  • reuse the reference ANSI sanitizer for Markdown and terminal help

This lets adopters such as mise select plain rendering after resolving their own color policy, even when clap-era color_print::cstr! help remains in command metadata.

Addresses the renderer behavior behind jdx/mise#12671.

Verification

  • mise run ci
  • cargo test -p gate --test fleet every_jdx_cli_matches_the_reference

AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.


Note

Low Risk
Output-formatting change limited to stripping escape bytes on plain paths; coloured terminal help is unchanged aside from shared finalization.

Overview
Plain help and docs no longer leak ANSI escapes that were already baked into command metadata (typical when migrating from clap/color_print::cstr! in fields like after_long_help).

The usage-argv renderer centralizes page finalization in finish_page: when Style::PLAIN is selected it strips complete CSI sequences before trim/newline, while coloured output keeps both renderer styling and any authored escapes. The Go argv renderer applies the same rule in assemble via stripANSISequences, since it only emits plain pages.

usage-lib adds a shared docs::strip_ansi helper (regex-based) and wires it into CLI plain rendering and Markdown generation, replacing a duplicate SGR regex in the markdown renderer. Style::PLAIN is documented to include this sanitization.

Tests cover Rust argv, Go argv, and usage-lib styled vs plain behaviour for authored ANSI in long help.

Reviewed by Cursor Bugbot for commit 718cd86. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx enabled auto-merge (squash) September 1, 2026 15:28
@jdx
jdx merged commit 662a765 into main Sep 1, 2026
10 checks passed
@jdx
jdx deleted the fix/help-plain-strip-ansi branch September 1, 2026 15:54
This was referenced Sep 1, 2026
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