arg: detect console width dynamically for CLI help wrapping#24989
Open
tanishqtayade wants to merge 1 commit into
Open
arg: detect console width dynamically for CLI help wrapping#24989tanishqtayade wants to merge 1 commit into
tanishqtayade wants to merge 1 commit into
Conversation
Collaborator
|
please respect the PR description template |
Author
|
@ngxson ,PR description is now updated to align to the template (Overview / Additional info / Requirements), and AI usage notification added.
|
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.
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.