From: Michael Tremer Date: Sun, 15 Oct 2023 12:43:43 +0000 (+0000) Subject: cli: repolist: Upgrade to the new parser X-Git-Tag: 0.9.30~1508 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17e361e171beafe60247fec9e00c76a8796b6453;p=pakfire.git cli: repolist: Upgrade to the new parser Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/repolist.c b/src/cli/lib/repolist.c index 61c314603..c9bc4a357 100644 --- a/src/cli/lib/repolist.c +++ b/src/cli/lib/repolist.c @@ -18,18 +18,35 @@ # # #############################################################################*/ -#include +#include #include #include +#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; } diff --git a/src/cli/lib/repolist.h b/src/cli/lib/repolist.h index 5c25e6bfd..ff47ea987 100644 --- a/src/cli/lib/repolist.h +++ b/src/cli/lib/repolist.h @@ -21,8 +21,6 @@ #ifndef PAKFIRE_CLI_REPOLIST_H #define PAKFIRE_CLI_REPOLIST_H -#include - -int cli_repolist(struct pakfire* pakfire, int argc, char* argv[]); +int cli_repolist(void* data, int argc, char* argv[]); #endif /* PAKFIRE_CLI_REPOLIST_H */ diff --git a/src/cli/pakfire-builder.c b/src/cli/pakfire-builder.c index 28e32bf25..67d1efd44 100644 --- a/src/cli/pakfire-builder.c +++ b/src/cli/pakfire-builder.c @@ -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 },