# #
#############################################################################*/
+#include <argp.h>
+#include <syslog.h>
+
+typedef struct ctx {
+ int log_level;
+} ctx_t;
+
+const char* argp_program_version = PACKAGE_VERSION;
+
+static const char* args_doc = "TODO";
+
+enum {
+ OPT_DEBUG = 1,
+};
+
+static struct argp_option options[] = {
+ { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
+ { NULL },
+};
+
+static error_t parse(int key, char* arg, struct argp_state* state) {
+ ctx_t* ctx = state->input;
+
+ switch (key) {
+ case OPT_DEBUG:
+ ctx->log_level = LOG_DEBUG;
+ break;
+
+ // Ignore these
+ case ARGP_KEY_END:
+ case ARGP_KEY_ERROR:
+ case ARGP_KEY_INIT:
+ case ARGP_KEY_FINI:
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+
+ return 0;
+}
+
int main(int argc, char* argv[]) {
+ int r;
+
+ // Create the context
+ ctx_t ctx = {};
+
+ // Setup the command line parser
+ struct argp parser = {
+ .options = options,
+ .parser = parse,
+ .args_doc = args_doc,
+ };
+ int arg_index = 0;
+
+ // Parse the command line
+ r = argp_parse(&parser, argc, argv, ARGP_IN_ORDER, &arg_index, &ctx);
+ if (r)
+ return r;
+
return 0;
}