Skip to content

Show built-in option defaults in --help regardless of overrides#401

Open
gmipf wants to merge 1 commit into
superg:mainfrom
gmipf:fix-help-default-leak
Open

Show built-in option defaults in --help regardless of overrides#401
gmipf wants to merge 1 commit into
superg:mainfrom
gmipf:fix-help-default-leak

Conversation

@gmipf

@gmipf gmipf commented Jun 29, 2026

Copy link
Copy Markdown

printUsage() formats the "(default: …)" hint for several value options from the parsed Options members. Because options are parsed before --help is handled, passing one of these together with --help prints the supplied value as the "default".

Before (b726, current main):

$ redumper --retries=9 --skip-fill=170 --plextor-leadin-retries=99 --scsi-timeout=12345 --help
	--retries=VALUE                 	number of sector retries in case of SCSI/C2 error (default: 9)
	--plextor-leadin-retries=VALUE  	maximum number of lead-in retries per session (default: 99)
	--skip-fill=VALUE               	fill byte value for skipped sectors (default: 0xAA)
	--scsi-timeout=VALUE            	SCSI command timeout, milliseconds (default: 12345)

After (this PR):

$ redumper --retries=9 --skip-fill=170 --plextor-leadin-retries=99 --scsi-timeout=12345 --help
	--retries=VALUE                 	number of sector retries in case of SCSI/C2 error (default: 0)
	--plextor-leadin-retries=VALUE  	maximum number of lead-in retries per session (default: 4)
	--skip-fill=VALUE               	fill byte value for skipped sectors (default: 0x55)
	--scsi-timeout=VALUE            	SCSI command timeout, milliseconds (default: 50000)

The same drift also affected --mediatek-leadout-retries, --audio-silence-threshold and --cdr-error-threshold. Plain redumper --help (no overrides) is unchanged.

Fix

Source these defaults from shared static constexpr *_default constants used both to initialize the members and to render the help text, so --help always shows the compile-time default regardless of argv. One file, no behavior change beyond the help text.

Verification

Built and tested in a container matching the CI toolchain (Ubuntu 24.04, clang-18 / libc++-18):

  • clang-format-18 --dry-run -Werror options.ixx — clean
  • ctest — 358/358 passed
  • before/after as shown above

This is the one self-contained fix split out of #400 (man-page generator, which I'm withdrawing).

Prepared with AI assistance (Claude Opus 4.8) and reviewed before submission.

Summary by CodeRabbit

  • Bug Fixes
    • Improved how default values are shown in the command-line help, so the displayed defaults now match the app’s built-in settings.
    • Standardized several numeric option defaults to make behavior more consistent when options are overridden at startup.

printUsage() formatted the "(default: ...)" hint for several value
options from the parsed Options members. Since options are parsed before
--help is handled, "redumper --retries=9 --help" printed the supplied
value (9) as the default instead of the built-in 0. The same drift
affected --skip-fill, --plextor-leadin-retries, --mediatek-leadout-retries,
--audio-silence-threshold, --cdr-error-threshold and --scsi-timeout.

Source these defaults from shared static constexpr *_default constants
used both to initialize the members and to render the help text, so
--help always shows the compile-time default. Plain --help is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a53b2605-797c-45c6-b245-42ed01d54cff

📥 Commits

Reviewing files that changed from the base of the PR and between cbf7c9b and 82d3972.

📒 Files selected for processing (1)
  • options.ixx

📝 Walkthrough

Walkthrough

Seven static constexpr *_default constants are added to gpsxre::Options in options.ixx. The constructor initializer list is updated to use these constants instead of hardcoded literals, and printUsage() is updated to reference the same constants for displayed default values.

Changes

Compile-time default constants for Options

Layer / File(s) Summary
Default constants and constructor initialization
options.ixx
Adds seven static constexpr *_default constants and updates the Options constructor initializer list to use them instead of literals.
printUsage() default placeholders
options.ixx
Updates all printUsage() format strings to reference the *_default constants instead of member values for displayed defaults.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A constant default, no longer a guess,
Compile-time values to keep things in dress.
The usage now shows what was baked in from the start,
No runtime surprises — just pure constant art!
Hop hop hooray for the tidy new code! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: help output now shows built-in defaults even when options are overridden.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant