Skip to content

arg: detect console width dynamically for CLI help wrapping#24989

Open
tanishqtayade wants to merge 1 commit into
ggml-org:masterfrom
tanishqtayade:feature/dynamic-console-width
Open

arg: detect console width dynamically for CLI help wrapping#24989
tanishqtayade wants to merge 1 commit into
ggml-org:masterfrom
tanishqtayade:feature/dynamic-console-width

Conversation

@tanishqtayade

@tanishqtayade tanishqtayade commented Jun 24, 2026

Copy link
Copy Markdown

Overview:-

Make CLI help text wrapping depend on the actual console width instead of a
fixed 70-character limit, improving readability across different terminals and
addressing the existing TODO in 'common/arg.cpp'.

Additional information:-

Add a small 'get_console_width()' helper in 'common/arg.cpp':
On Windows, use 'GetConsoleScreenBufferInfo()' to get the console width.
On POSIX systems, use 'ioctl(TIOCGWINSZ)' to get 'ws_col'.
On Emscripten or when width detection fails, fall back to 70 characters to preserve existing behavior.
Use this width to compute 'n_char_per_line_help' in 'common_arg::to_string()'.
This addresses the existing TODO in 'common/arg.cpp':
'// TODO: detect this based on current console'.

Requirements:-
I have read and agree with the contributing guidelines.
AI usage disclosure: I used an AI assistant to help draft and refine this change and description, and I have reviewed, built, and tested the code myself.

@tanishqtayade tanishqtayade requested a review from a team as a code owner June 24, 2026 21:54
@ngxson

ngxson commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

please respect the PR description template

@tanishqtayade

tanishqtayade commented Jun 25, 2026

Copy link
Copy Markdown
Author

@ngxson ,PR description is now updated to align to the template (Overview / Additional info / Requirements), and AI usage notification added.
The change is limited to 'common/arg.cpp', and I’ve tested on Windows with:

  • '.\build\bin\Release\llama.exe cli --help'
  • '.\build\bin\Release\test-arg-parser.exe'
    Please let me know if you need anything changed in the workflow or naming.

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.

2 participants