Skip to content

fix(docs): show negated flags in cli help#694

Merged
jdx merged 1 commit into
mainfrom
codex/show-negated-flags-in-help
Jun 23, 2026
Merged

fix(docs): show negated flags in cli help#694
jdx merged 1 commit into
mainfrom
codex/show-negated-flags-in-help

Conversation

@jdx

@jdx jdx commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • show negated boolean flag aliases in CLI help as --flag / --no-flag
  • use the displayed flag usage when calculating help column widths
  • add CLI help snapshots for short and long negated flag output

Validation

  • cargo fmt --all
  • cargo test -p usage-lib --features docs

Note

Low Risk
Docs-only CLI help rendering and tests; no parsing or runtime flag behavior changes.

Overview
CLI help for boolean flags with a negate alias now shows both forms as --flag / --no-flag instead of only the positive option.

A new display_usage field on doc SpecFlag builds that string from usage and negate. Short and long Tera templates render display_usage instead of usage, and flag column width for aligned long help is computed from display_usage so wider negated pairs still line up with descriptions.

Snapshot tests cover short and long help for a --compress / --no-compress example.

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

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jdx, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 20 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a367ff5-87b5-4140-bcad-0d2045711dfb

📥 Commits

Reviewing files that changed from the base of the PR and between 4aa5d56 and 13b02a5.

📒 Files selected for processing (4)
  • lib/src/docs/cli/mod.rs
  • lib/src/docs/cli/templates/spec_template_long.tera
  • lib/src/docs/cli/templates/spec_template_short.tera
  • lib/src/docs/models.rs

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.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds proper rendering of negated boolean flags in CLI help output, displaying them as --flag / --no-flag instead of only --flag. The column-width calculation is also updated to measure display_usage (the full negated form) rather than the bare usage string, so help text stays aligned correctly when a negate alias is present.

  • A new display_usage field is computed at conversion time in SpecFlag::from, and both Tera templates swap from flag.usage to flag.display_usage, covering both the padded long format and the compact short format.
  • Snapshot tests exercise both render_help modes (short and long) with a negated flag to pin the alignment behaviour.

Confidence Score: 5/5

Safe to merge — changes are additive and well-tested with matching snapshots.

The change is narrow: one new derived field, two template substitutions, and matching snapshot tests. The refactor of the two-pass flag-collection correctly moves column-width measurement to use the longer display_usage string, and the original usage field is preserved untouched for any other consumers. No existing behaviour is altered for flags without a negate alias.

No files require special attention.

Important Files Changed

Filename Overview
lib/src/docs/models.rs Adds display_usage to SpecFlag, computed as "--flag / --no-flag" when a negate exists; refactors column-width calculation to use display_usage lengths instead of usage lengths.
lib/src/docs/cli/mod.rs Adds snapshot tests for both short and long CLI help output when a flag has a negate alias, covering alignment behaviour in both modes.
lib/src/docs/cli/templates/spec_template_long.tera Replaces flag.usage with flag.display_usage in both the aligned (help present) and bare (no help) rendering paths.
lib/src/docs/cli/templates/spec_template_short.tera Replaces flag.usage with flag.display_usage in the short help template; no other changes.

Reviews (1): Last reviewed commit: "fix(docs): show negated flags in cli hel..." | Re-trigger Greptile

@jdx jdx merged commit 8fdbfeb into main Jun 23, 2026
6 checks passed
@jdx jdx deleted the codex/show-negated-flags-in-help branch June 23, 2026 18:32
@greptile-apps greptile-apps Bot mentioned this pull request Jun 23, 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