Allow turning a switch off from the CLI (-switch=false)#162
Merged
Conversation
Switches were only recognized in the no-"=" branch, where they are unconditionally turned on. Any token with "=" went to the option path, so -gui=false was parsed as an option named "gui" — which doesn't exist (it's a switch) — and exited with "The option gui is not known to this system." A switch enabled in a YAML file therefore could not be overridden off on the command line, contradicting the documented CLI-over-YAML precedence. Intercept -<switch>=<bool> before the option branch and route true/1 to turnOn() and false/0 to turnOff() (both already exist in GSwitch); reject other values. The bare -switch form still works via the existing branch. Verified: -printSystemsMaterials=true prints materials, =false suppresses them (the off override takes effect), and =maybe is rejected with "accepts only true/false" (Geant4 11.4.1 dev container). Fixes gemc#131 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Switches were only recognized in the no-
=branch, where they are unconditionally turned on. Any token with=went to the option path, so-gui=falsewas parsed as an option namedgui— which doesn't exist (it's a switch) — and exited with "The option gui is not known to this system." A switch enabled in a YAML file therefore could not be overridden off on the command line, contradicting the documented CLI-over-YAML precedence.Intercept
-<switch>=<bool>before the option branch and routetrue/1toturnOn()andfalse/0toturnOff()(both already exist inGSwitch); reject other values. The bare-switchform still works via the existing branch.Validation: ran in the Geant4 11.4.1 dev container against the b1 example:
-printSystemsMaterials=trueprints 10 materials,-printSystemsMaterials=falseprints 0 (the off override actually takes effect), and-printSystemsMaterials=maybeis rejected with "accepts only true/false".Fixes #131