Repository navigation
Make cobra help output respect the terminal width - #6
Merged
Merged
Conversation
Help was the last unwrapped surface: cobra's default template emits flag usages via FlagUsages, which never wraps, so long descriptions hard-wrapped at the terminal's right edge with continuations at column zero while the flags themselves sat indented mid-line. Long descriptions rendered verbatim, and cobra's built-in completion summaries overflowed narrow terminals. The usage template is now patched in place (not copied, so it tracks cobra's default) to use pflag's FlagUsagesWrapped at the measured width, which aligns continuations under each description. Long descriptions re-wrap at runtime, the trailing use-hint breaks below 78 columns, the completion commands are hidden from the list (still invocable), command summaries were shortened to fit the list column, and the init --forge default URL moved out of the flag line — an unbreakable token that cannot fit pflag's description column at narrow widths. Verified by capturing every help screen in a PTY at 60 and 80 columns and measuring display widths: zero over-width lines, continuations aligned. 💘 Generated with Crush Assisted-by: Crush:rits/zai-org/glm-5-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Help was the last unwrapped output surface: cobra's default template renders flag usages via
FlagUsages, which never wraps — long descriptions hard-wrapped at the terminal's right edge with continuations at column zero while the flags sat indented mid-line. Long descriptions rendered verbatim, and cobra's built-in completion summaries overflowed narrow terminals.FlagUsagesWrappedat the measured terminal width. Templates inherit from the root, covering every subcommand.Use "… [command] --help"hint breaks onto two lines below 78 columns.--forgedefault URL moved out of the flag line into the usage text — an unbreakable token that cannot fit pflag's description column at narrow widths (the wizard still shows it as the placeholder, and empty--forgekeeps the same default).Verification
Every help screen (
--helpon root, run, init, report, ledger subcommands) captured in a PTY at 60 and 80 columns with ANSI-aware width measurement: zero over-width lines, continuations aligned. Full suite with race detector, vet, staticcheck clean.💘 Generated with Crush