Skip to content

fix(cli): prevent mid-word truncation in winml --help summaries#816

Open
ziyuanguo1998 wants to merge 1 commit into
mainfrom
ziyuan/511-fix-help-truncation
Open

fix(cli): prevent mid-word truncation in winml --help summaries#816
ziyuanguo1998 wants to merge 1 commit into
mainfrom
ziyuan/511-fix-help-truncation

Conversation

@ziyuanguo1998
Copy link
Copy Markdown
Contributor

Summary

Fixes #511.

winml --help truncated each subcommand summary mid-word because
LazyGroup.format_commands hard-sliced the help text at a fixed character
count (help_text[:limit]), landing inside a token — e.g. build rendered as
…HuggingFace model or .on.

Fix

Drop the manual character-slice truncation and hand the full first docstring
line to Click's HelpFormatter.write_dl, which already wraps long descriptions
at word boundaries with a hanging indent, respecting terminal width. The
zero-import AST extraction of the help text is unchanged.

Before:

build     Build a WinML-optimized ONNX model from a HuggingFace model or .on

After:

build     Build a WinML-optimized ONNX model from a HuggingFace model or
          .onnx file.

Tests

Adds TestNoMidWordTruncation in tests/cli/test_help_cli.py:

  • every enabled command's complete summary survives in --help output, never truncated
  • at a forced narrow width the longest summary wraps with no overflow and no mid-token cut

tests/cli/ passes (223 passed).

🤖 Generated with Claude Code

LazyGroup.format_commands was hard-slicing help text at a fixed character
count, landing mid-word (e.g. "…model or .on"). Instead, pass the full
first docstring line to Click's write_dl, which wraps at word boundaries
with proper indentation, respecting terminal width.

Add regression tests to ensure complete summaries appear in --help output
at any terminal width, with no mid-token cuts.
@ziyuanguo1998 ziyuanguo1998 requested a review from a team as a code owner June 5, 2026 06:47
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.

[winml] [P2] Subcommand descriptions in winml --help are truncated mid-word

2 participants