#include #include #include "options.h" #include "logging.h" static void print_usage(const char *progname) { printf("Usage: %s [-c config_file] [-v[v[v]]] [-q[q[q]]] [-h]\n" " -v Increase output verbosity\n" " -q Decrease output verbosity\n" " -c Specifiy configuration file to read (default 'config.lua')\n" " -h Print this help message and exit\n", progname); } int parse_options(struct argent_options *opts, int argc, char **argv) { opts->log_level = WARN; opts->conf_filename = "config.lua"; int opt; while ((opt = getopt(argc, argv, "hqvc:")) != -1) { switch (opt) { case 'q': opts->log_level -= 1; break; case 'v': opts->log_level += 1; break; case 'c': opts->conf_filename = optarg; break; case 'h': print_usage(argv[0]); return 2; default: print_usage(argv[0]); return 1; } } // ew, globals (sorry) argent_log_level = opts->log_level; return 0; }