]> git.ipfire.org Git - pakfire.git/commitdiff
cli: repolist: Upgrade to the new parser
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Oct 2023 12:43:43 +0000 (12:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Oct 2023 12:43:43 +0000 (12:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/repolist.c
src/cli/lib/repolist.h
src/cli/pakfire-builder.c

index 61c31460390bf572e395ff0dd4c765b243d3ecb2..c9bc4a357d263eecf1bd78933bdf7663de044af0 100644 (file)
 #                                                                             #
 #############################################################################*/
 
-#include <errno.h>
+#include <argp.h>
 
 #include <pakfire/pakfire.h>
 #include <pakfire/repolist.h>
 
+#include "command.h"
 #include "dump.h"
+#include "pakfire.h"
 #include "repolist.h"
 
-int cli_repolist(struct pakfire* pakfire, int argc, char* argv[]) {
+static const char* doc = "List all available repositories";
+
+int cli_repolist(void* data, int argc, char* argv[]) {
+       struct pakfire* pakfire = NULL;
        struct pakfire_repolist* list = NULL;
        int r;
 
+       struct cli_config* cli_config = data;
+
+       // Parse the command line
+       r = cli_parse(NULL, NULL, NULL, doc, NULL, argc, argv, NULL);
+       if (r)
+               goto ERROR;
+
+       // Setup Pakfire
+       r = cli_setup_pakfire(&pakfire, cli_config);
+       if (r)
+               goto ERROR;
+
        // Fetch all repositories
        list = pakfire_get_repos(pakfire);
        if (!list) {
@@ -43,6 +60,8 @@ int cli_repolist(struct pakfire* pakfire, int argc, char* argv[]) {
 ERROR:
        if (list)
                pakfire_repolist_unref(list);
+       if (pakfire)
+               pakfire_unref(pakfire);
 
        return r;
 }
index 5c25e6bfd8d2d9368163b8b060e8468c7ea47b35..ff47ea98744891a7c270b4085390bef137489095 100644 (file)
@@ -21,8 +21,6 @@
 #ifndef PAKFIRE_CLI_REPOLIST_H
 #define PAKFIRE_CLI_REPOLIST_H
 
-#include <pakfire/pakfire.h>
-
-int cli_repolist(struct pakfire* pakfire, int argc, char* argv[]);
+int cli_repolist(void* data, int argc, char* argv[]);
 
 #endif /* PAKFIRE_CLI_REPOLIST_H */
index 28e32bf2505f118aa5e61bcf7cab612807447b02..67d1efd44f7e72ae1135d3b178c007ac39f55732 100644 (file)
@@ -71,10 +71,11 @@ static const struct command commands[] = {
        { "info",     cli_info,     1, -1, 0 },
        { "provides", cli_provides, 1, -1, 0 },
        { "repo",     cli_repo,    -1, -1, 0 },
+       { "repolist", cli_repolist, 0,  0, 0 },
        { "requires", cli_requires, 1, -1, 0 },
        { "search",   cli_search,   1, -1, 0 },
+
 #if 0
-       { "repolist", 0, cli_repolist },
        { "shell",    0, cli_shell },
 #endif
        { NULL },