Skip to content

PrintUsage emits fixed-width help text; ignores detected GetWindowWidth #1672

Description

@Widthdom

Summary

ConsoleUi.PrintUsage() emits long usage lines (some ~180 chars wide) without consulting GetWindowWidth(), even though GetWindowWidth() exists for the spinner / progress-bar code path. On 80-column terminals (CI logs, default tmux panes, narrow SSH windows) usage text wraps mid-flag and becomes unreadable. On wider terminals the text uses only the leftmost 80 columns, wasting screen real estate.

Distinct from #1629 (GetWindowWidth catches all exceptions and returns 80) — that fixes the width detection; C270 is that PrintUsage doesn't use the detected width regardless of #1629's outcome.

Where

  • src/CodeIndex/Cli/ConsoleUi.cs:330-450 (PrintUsage — fixed-width output)
  • src/CodeIndex/Cli/ConsoleUi.cs:858-868 (GetWindowWidth — already implemented but unused here)

Suggested approach

(1) Wire PrintUsage to wrap option descriptions at min(GetWindowWidth(), 120) columns, preserving the option-name column. (2) For pipes / non-TTY (already detected via ShouldUseInteractiveConsole), fall back to the current fixed format. (3) Verify against cdidx --help | cat and COLUMNS=200 cdidx --help to confirm both narrow and wide cases render correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions