Skip to content

Allow turning a switch off from the CLI (-switch=false)#162

Merged
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/131-cli-switch-off
Jun 13, 2026
Merged

Allow turning a switch off from the CLI (-switch=false)#162
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/131-cli-switch-off

Conversation

@zhaozhiwen

Copy link
Copy Markdown
Collaborator

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.

Validation: ran in the Geant4 11.4.1 dev container against the b1 example: -printSystemsMaterials=true prints 10 materials, -printSystemsMaterials=false prints 0 (the off override actually takes effect), and -printSystemsMaterials=maybe is rejected with "accepts only true/false".

Fixes #131

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>
@maureeungaro maureeungaro merged commit c445ab6 into gemc:main Jun 13, 2026
30 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.

[Medium] Switches cannot be turned off from the CLI, breaking documented YAML-override precedence

2 participants