Skip to content

Fix help padding and preserve caller stream formatting - #435

Merged
p-ranav merged 4 commits into
p-ranav:masterfrom
damnbrocrazy-svg:master
Oct 1, 2026
Merged

p-ranav merged 4 commits into
p-ranav:masterfrom
damnbrocrazy-svg:master

Conversation

@damnbrocrazy-svg

Copy link
Copy Markdown
Contributor

Printing help to a stream previously configured with std::setfill('0') pads argument names with zeros (for example, mode000000000). The help formatter also leaves std::left set 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):

  • Original suite: 250 tests and 905 assertions passed; one existing test skipped.
  • Both new regression tests fail against the original header (seven failed assertions).
  • Patched full suite: 252 tests and 918 assertions passed; the same existing test skipped.
  • git diff --check passed. 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.

@p-ranav
p-ranav merged commit 9b8aae8 into p-ranav:master Oct 1, 2026
6 of 8 checks passed
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.

Formatting uses trailing zeros when using std::cout << program'

2 participants