#include #include #include #include #include #include #include static const char *const usage[] = { "core [options] [[--] args]", "core [options]", NULL, }; void helper_parse_cli(int argc, const char **argv, config_t *config) { struct argparse_option options[] = { OPT_HELP(), OPT_GROUP("Basic options"), OPT_STRING('c', "config", &config->file, "path to config file", NULL, 0, OPT_NONEG), OPT_END(), }; struct argparse argparse; argparse_init(&argparse, options, usage, 0); argparse_describe( &argparse, "\nA brief description of what the program does and how it works.", "\nAdditional description of the program after the description of the arguments." ); argc = argparse_parse(&argparse, argc, argv); if(argc == 1) { config->run_type = RUN_TYPE_INVALID; if(strcmp(argv[0], "start") == 0) { config->run_type = RUN_TYPE_START; return; } LOG_FATAL("bad action '%s' given ('start')\n", argv[0]); exit(1); } else { LOG_FATAL("no action given ('start')\n"); exit(1); } return; }