Repository navigation
Fix help padding and preserve caller stream formatting - #435
Merged
Merged
Conversation
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.
Printing help to a stream previously configured with
std::setfill('0')pads argument names with zeros (for example,mode000000000). The help formatter also leavesstd::leftset on the caller's stream.Use space fill and left alignment while rendering help, then restore the original formatting flags and fill character with a local RAII guard, including when writing throws. This leaves existing width behavior unchanged. The regression tests cover positional/optional arguments, multiline help, subcommands, subsequent formatted output, and restoration after a failed write.
Fixes #409.
Validation on Windows with MinGW g++ 13.2, C++17, and the test CMakeLists.txt warning flags (including
-Werror):git diff --checkpassed. Uploaded source and test files were compared byte-for-byte with the local files.AI assistance was used for implementation and review. The reported compiler and test checks were executed locally; other platforms have not been tested locally.