GOptions : provides a unified framework to define, parse, validate, and persist configuration coming from YAML files and command-line arguments. It is designed to support:
small executables (a handful of options),
large frameworks/plugins (many modules contributing options),
reproducible batch workflows (automatic YAML snapshot of resolved configuration).
The subsystem is built around:
GSwitch : a presence-based boolean flag (e.g. -gui).
GOption : an option value container that can be scalar or structured.
GVariable : a schema entry used when defining scalar options or structured option keys.
Configuration sources are resolved in increasing precedence: schema defaults, YAML input, and finally command-line values. Dot-notation command-line updates replace one structured subkey without requiring the complete option value to be repeated.
Configuration source precedence and structured updates
This module defines two conventional structured options commonly used across the project:
verbosity (integer levels)
debug (boolean or integer)
Typical semantics used by classes that consume these settings:
Level 0: minimal output ("shush") — only essential messages.
Level 1: detailed informational output — key configuration and progress.
Level 2: extra detailed output — expanded per-step or per-event diagnostics.
debug=true (or debug > 0): developer-focused diagnostics — internal state, parsing details, and other troubleshooting information beyond normal verbosity.
Examples
The following example program is provided with this module:
examples/define_options.cc : Defines switches and options (scalar + structured), constructs a parsing GOptions : instance, and reads back resolved values with typed getters.
Extensibility via merging option definitions
Frameworks or plugins can define their own options and switches, then merge them into the executable’s definition set using operator+=() (which internally calls addGOptions()).
YAML parsing is implemented using the yaml-cpp library. When a YAML file fails to parse, the option manager exits with a dedicated exit code so batch workflows can detect the failure mode.
Ownership and maintenance
The goptions module is maintained as part of GEMC and is intended to be:
stable at the API level for consumers of GOptions : ,
strict and explicit about error reporting (exit codes) for batch reproducibility,
documentation-first: headers contain authoritative API docs; implementation files avoid duplication.