|
goptions
|
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:
The subsystem is built around:
-gui).A GSwitch : is a lightweight boolean flag:
-<name> on the command line turns it on.Example:
A scalar GOption : stores exactly one value as a YAML scalar. Values can be supplied via:
A structured GOption : stores either:
A typical pattern is a sequence of maps where each entry represents one repeated item:
Equivalent command-line option (quotes are usually required so your shell does not split the string):
Structured options can be declared cumulative when at least one schema key uses goptions::NODFLT : as its default value. That tells GOption : that:
Missing non-mandatory keys are back-filled from schema defaults so every entry becomes complete.
Some structured options are updated using dot-notation:
This updates a single subkey within a structured option via set_sub_option_value() .
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:
debug=true (or debug > 0): developer-focused diagnostics — internal state, parsing details, and other troubleshooting information beyond normal verbosity.The following example program is provided with this module:
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()).
Example:
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.
The goptions module is maintained as part of GEMC and is intended to be: