16 GVariable(
"optional_string", std::nullopt,
"optional string used by this test"),
17 "An unset value must be returned as std::nullopt.");
19 GVariable(
"optional_int", std::nullopt,
"optional integer used by this test"),
20 "An unset value must be returned as std::nullopt.");
21 options.
defineOption(
GVariable(
"required_string",
"configured",
"required string used by this test"),
"");
29int main(
int argc,
char* argv[]) {
30 std::optional<std::string> expected;
31 std::optional<int> expectedInt;
32 const std::string option_prefix =
"-optional_string=";
33 const std::string int_option_prefix =
"-optional_int=";
34 for (
int index = 1; index < argc; ++index) {
35 const std::string argument = argv[index];
36 if (argument.rfind(option_prefix, 0) == 0) {
37 expected = argument.substr(option_prefix.size());
39 if (argument.rfind(int_option_prefix, 0) == 0) {
40 expectedInt = std::stoi(argument.substr(int_option_prefix.size()));
54 if (!value || *value != *expected)
return 1;
56 else if (value)
return 1;
57 return intValue == expectedInt ? 0 : 1;
Parses, stores, and exposes command-line options and YAML configuration values.
double getRequiredScalarDouble(const std::string &tag) const
Retrieves the required value of a scalar double option.
void defineOption(const GVariable &gvar, const std::string &help)
Defines and adds a scalar option.
std::optional< std::string > getOptionalScalarString(const std::string &tag) const
Retrieves the optional value of a scalar string option.
std::string getRequiredScalarString(const std::string &tag) const
Retrieves the required value of a scalar string option.
std::optional< int > getOptionalScalarInt(const std::string &tag) const
int getRequiredScalarInt(const std::string &tag) const
Retrieves the required value of a scalar integer option.
Public interface for GOptions : the YAML + command-line configuration manager.
int main(int argc, char *argv[])
Describes a schema entry: key name, default value, and user-facing description.