From: Michael Tremer Date: Sat, 14 Oct 2023 18:07:56 +0000 (+0000) Subject: cli: Update clean command to the new parser X-Git-Tag: 0.9.30~1522 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7720452bad7b0ef80b726e70b0279865ba85fc0;p=pakfire.git cli: Update clean command to the new parser Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/clean.c b/src/cli/lib/clean.c index 735be22a2..61c5fad90 100644 --- a/src/cli/lib/clean.c +++ b/src/cli/lib/clean.c @@ -21,7 +21,31 @@ #include #include "clean.h" +#include "command.h" +#include "pakfire.h" -int cli_clean(struct pakfire* pakfire, int argc, char* argv[]) { - return pakfire_clean(pakfire, 0); +int cli_clean(void* data, int argc, char* argv[]) { + struct pakfire* pakfire = NULL; + int r; + + struct cli_config* config = data; + + // Parse the command line + r = cli_parse(NULL, NULL, NULL, NULL, argc, argv, NULL); + if (r) + goto ERROR; + + // Setup Pakfire + r = cli_setup_pakfire(&pakfire, config); + if (r) + goto ERROR; + + // Clean! + r = pakfire_clean(pakfire, 0); + +ERROR: + if (pakfire) + pakfire_unref(pakfire); + + return r; } diff --git a/src/cli/lib/clean.h b/src/cli/lib/clean.h index 68f807526..c03912938 100644 --- a/src/cli/lib/clean.h +++ b/src/cli/lib/clean.h @@ -21,8 +21,6 @@ #ifndef PAKFIRE_CLI_CLEAN_H #define PAKFIRE_CLI_CLEAN_H -#include - -int cli_clean(struct pakfire* pakfire, int argc, char* argv[]); +int cli_clean(void* data, int argc, char* argv[]); #endif /* PAKFIRE_CLI_CLEAN_H */ diff --git a/src/cli/lib/command.c b/src/cli/lib/command.c index 7ac7b920d..ec9d15c2a 100644 --- a/src/cli/lib/command.c +++ b/src/cli/lib/command.c @@ -161,7 +161,7 @@ int cli_parse(const struct argp_option* options, const struct command* commands, int arg_index = 0; // Parse command line options - r = argp_parse(&parser, argc, argv, ARGP_IN_ORDER, &arg_index, &ctx); + r = argp_parse(options ? &parser : NULL, argc, argv, ARGP_IN_ORDER, &arg_index, &ctx); if (r) return r; diff --git a/src/cli/pakfire-builder.c b/src/cli/pakfire-builder.c index 60c7265c4..fe152ad40 100644 --- a/src/cli/pakfire-builder.c +++ b/src/cli/pakfire-builder.c @@ -65,8 +65,8 @@ static struct argp_option options[] = { static const struct command commands[] = { { "build", CLI_REQUIRE_ONE_OR_MORE_ARGUMENTS, cli_build }, -#if 0 { "clean", 0, cli_clean }, +#if 0 { "dist", 0, cli_dist }, { "image", 0, cli_image }, { "info", 0, cli_info },