19 #include <glog/logging.h> 24 DEFINE_bool(flag_bool_true,
true,
"Bool with true default value");
25 DEFINE_bool(flag_bool_false,
false,
"Bool with false default value");
35 printf(
"%s %s\n", name.c_str(), folly::to<std::string>(
v.as<
T>()).c_str());
40 po::options_description desc;
41 auto styleEnv = getenv(
"PROGRAM_OPTIONS_TEST_STYLE");
43 CHECK(styleEnv) <<
"PROGRAM_OPTIONS_TEST_STYLE is required";
44 bool gnuStyle = !strcmp(styleEnv,
"GNU");
45 CHECK(gnuStyle || !strcmp(styleEnv,
"GFLAGS"))
46 <<
"Invalid value for PROGRAM_OPTIONS_TEST_STYLE";
58 po::store(result.options, vm);
61 if (vm.count(
"help")) {
66 print<bool>(vm, gnuStyle ?
"flag-bool-true" :
"flag_bool_true");
67 print<bool>(vm, gnuStyle ?
"flag-bool-false" :
"flag_bool_false");
68 print<int32_t>(vm, gnuStyle ?
"flag-int" :
"flag_int");
69 print<std::string>(vm, gnuStyle ?
"flag-string" :
"flag_string");
72 printf(
"command %s\n", result.command->c_str());
75 for (
auto& arg : result.rest) {
76 printf(
"arg %s\n", arg.c_str());
int main(int argc, char *argv[])
DEFINE_bool(flag_bool_true, true,"Bool with true default value")
NestedCommandLineParseResult parseNestedCommandLine(int argc, const char *const argv[], const po::options_description &desc)
DEFINE_string(flag_string,"foo","String flag")
po::options_description getGFlags(ProgramOptionsStyle style)
DEFINE_int32(flag_int, 42,"Integer flag")