17 static optcfg_option options[] = {
18 // short, long, id, desc
19 {0, "vr", OPT_VR, "enable VR mode"},
20 {0, "srgb", OPT_SRGB, "use linear color space"},
21 {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"},
22 {'w', "windowed", OPT_WINDOWED, "run in windowed mode"},
23 {'h', "help", OPT_HELP, "print usage and exit"},
27 static int opt_handler(optcfg *oc, int opt, void *cls);
29 bool init_options(int argc, char **argv, const char *cfgfile)
32 memset(&opt, 0, sizeof opt);
35 optcfg *oc = optcfg_init(options);
36 optcfg_set_opt_callback(oc, opt_handler, 0);
38 if(cfgfile && optcfg_parse_config_file(oc, cfgfile) == -1) {
43 if(argv && optcfg_parse_args(oc, argc, argv) == -1) {
44 fprintf(stderr, "invalid option\n");
53 static bool is_enabled(optcfg *oc)
56 optcfg_enabled_value(oc, &res);
60 static int opt_handler(optcfg *oc, int optid, void *cls)
64 opt.vr = is_enabled(oc);
68 opt.srgb = is_enabled(oc);
72 opt.fullscreen = is_enabled(oc);
76 opt.fullscreen = !is_enabled(oc);
80 printf("Usage: vrfileman [options]\nOptions:\n");
81 optcfg_print_options(oc);