]> git.ipfire.org Git - pakfire.git/commitdiff
cli: Update clean command to the new parser
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Oct 2023 18:07:56 +0000 (18:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Oct 2023 18:07:56 +0000 (18:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/clean.c
src/cli/lib/clean.h
src/cli/lib/command.c
src/cli/pakfire-builder.c

index 735be22a2f76cce3c8ef7abfb7ec356afb6b1a88..61c5fad906ab91e450b130af08860ed073b365a4 100644 (file)
 #include <pakfire/pakfire.h>
 
 #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;
 }
index 68f80752685222f3d06eaf2150cc30db046486b4..c039129388286cb03310bc560ef78f9eaffeb597 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef PAKFIRE_CLI_CLEAN_H
 #define PAKFIRE_CLI_CLEAN_H
 
-#include <pakfire/pakfire.h>
-
-int cli_clean(struct pakfire* pakfire, int argc, char* argv[]);
+int cli_clean(void* data, int argc, char* argv[]);
 
 #endif /* PAKFIRE_CLI_CLEAN_H */
index 7ac7b920dcf39418f24a17aa80644cc141f89218..ec9d15c2a05ebe2d9c2346f076bafef8ff444804 100644 (file)
@@ -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;
 
index 60c7265c401d7b696a97a7f9d1c8151e1c6616aa..fe152ad40d115ed377b76a31f2598d8aa252b6e7 100644 (file)
@@ -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 },