From: Michael Tremer Date: Tue, 17 Oct 2023 10:36:04 +0000 (+0000) Subject: cli: client: Add a --debug switch X-Git-Tag: 0.9.30~1459 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d5c1177d3adf705b9fe0bd9f250d5973a7747d2;p=pakfire.git cli: client: Add a --debug switch Signed-off-by: Michael Tremer --- diff --git a/src/cli/pakfire-client.c b/src/cli/pakfire-client.c index 512add586..59877d735 100644 --- a/src/cli/pakfire-client.c +++ b/src/cli/pakfire-client.c @@ -19,6 +19,7 @@ #############################################################################*/ #include +#include #include @@ -38,6 +39,30 @@ static const char* args_doc = static const char* doc = "The Pakfire Build Service Client Tool"; +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, void* data) { + struct pakfire_ctx* ctx = data; + + switch (key) { + case OPT_DEBUG: + pakfire_ctx_set_log_level(ctx, LOG_DEBUG); + break; + + default: + return ARGP_ERR_UNKNOWN; + } + + return 0; +} + int main(int argc, char* argv[]) { struct pakfire_ctx* ctx = NULL; int r; @@ -51,7 +76,7 @@ int main(int argc, char* argv[]) { pakfire_ctx_set_progress_callback(ctx, cli_setup_progressbar, NULL); // Parse the command line and run any commands - r = cli_parse(NULL, commands, args_doc, doc, NULL, argc, argv, ctx); + r = cli_parse(options, commands, args_doc, doc, parse, argc, argv, ctx); ERROR: if (ctx)