Enhance gitt help CLI output in small terminal size#389
Enhance gitt help CLI output in small terminal size#389dataCenter430 wants to merge 2 commits intoentrius:testfrom
gitt help CLI output in small terminal size#389Conversation
263913c to
7683ad6
Compare
gitt help CLI output in small terminal size
|
Hi, @anderdc |
|
why would someone not just rerun the command and expand their terminal size? It seems you're adding unnecessary complexity for an issue that doesn't really matter? |
|
Hi, @anderdc
For a new user, broken box rendering on first The change is ~50 lines behind a single Happy to tune the threshold if you'd prefer. |
|
Good, I also think so, @dataCenter430 |
|
Good enhancement, @dataCenter430 |
Summary
The
gitt --helpoutput uses Rich-powered panels and ratio-based columns which break visually on narrow or split-pane terminals. This PR adds a plain-text fallback that activates automatically when the terminal is too narrow to render the box layout cleanly.Root Cause
Two bugs combined to make the existing width-check ineffective:
ctx.terminal_widthis alwaysNone— Click does not populate this field on its own. Theor 120fallback meant the console was always created at 120 columns regardless of the real terminal width, so the width guard never fired.4:1:1:7) is already cramped at that size.Changes (
gittensor/cli/issue_commands/help.py)Width detection fix
Replaced
ctx.terminal_width or 120with a_terminal_width(ctx)helper that falls back toshutil.get_terminal_size(), which correctly reads the OS terminal dimensions.Threshold raised to 100
Terminals under 100 columns get plain text. The 4-column options panel needs real room; at 80 cols (standard terminal) it was always visually broken.
Plain-text rendering path
Three new helpers render help output without any Rich boxes when width is below the threshold:
_plain_usageUsage:line_plain_optionsOptions:section, two-column aligned_plain_sectionCommands:section, two-column aligned_plain_optionsalso handles long flag names gracefully: if a label would push the description off-screen, it uses a stacked layout (flag on its own line, description indented below) instead of an inline one. The label column is capped at half the usable terminal width.Behaviour
Testing
Verified manually at widths 40, 60, 79, 80, 99, 100, and 120 columns with both
StyledCommandandStyledGrouphelp output. No regressions on the wide-terminal path.Closes : #388
Screenshot
Before:
After: