From a7370423a67cf05458b786713e57887f72d542f0 Mon Sep 17 00:00:00 2001 From: ngn Date: Thu, 22 Aug 2024 01:07:51 +0300 Subject: [PATCH] update: add pool name to info command --- locale/tr/LC_MESSAGES/matt.po | 43 +++++++++++++++++++---------------- src/cmd/info.c | 15 +++++++----- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/locale/tr/LC_MESSAGES/matt.po b/locale/tr/LC_MESSAGES/matt.po index 267087c..b6fe03d 100644 --- a/locale/tr/LC_MESSAGES/matt.po +++ b/locale/tr/LC_MESSAGES/matt.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-17 19:06+0300\n" +"POT-Creation-Date: 2024-08-22 01:00+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -167,8 +167,8 @@ msgstr "To list different options, use commands with " msgid "Here is a list of available global options:" msgstr "Here is a list of available global options:" -#: src/main.c:199 src/main.c:200 src/cmd/info.c:54 src/cmd/info.c:55 -#: src/cmd/info.c:56 src/cmd/install.c:34 src/cmd/install.c:35 +#: src/main.c:199 src/main.c:200 src/cmd/info.c:52 src/cmd/info.c:53 +#: src/cmd/info.c:54 src/cmd/install.c:34 src/cmd/install.c:35 #: src/cmd/install.c:36 src/cmd/install.c:37 src/cmd/install.c:38 #: src/cmd/list.c:24 src/cmd/list.c:25 src/cmd/remove.c:28 src/cmd/remove.c:29 #: src/cmd/update.c:23 @@ -196,75 +196,80 @@ msgstr "Failed to run the editor: %s" msgid "Failed to open the editor: %s" msgstr "Failed to open the editor: %s" -#: src/cmd/info.c:19 src/cmd/info.c:29 src/cmd/install.c:91 src/cmd/remove.c:52 +#: src/cmd/info.c:17 src/cmd/info.c:27 src/cmd/install.c:91 src/cmd/remove.c:52 msgid "Package " msgstr "Package " -#: src/cmd/info.c:48 src/cmd/install.c:28 src/cmd/list.c:18 src/cmd/remove.c:22 +#: src/cmd/info.c:46 src/cmd/install.c:28 src/cmd/list.c:18 src/cmd/remove.c:22 #: src/cmd/sync.c:15 src/cmd/update.c:17 msgid "Unknown argument: " msgstr "Unknown argument: " -#: src/cmd/info.c:53 src/cmd/list.c:23 +#: src/cmd/info.c:51 src/cmd/list.c:23 msgid "Listing options for the list command:" msgstr "Listing options for the list command:" -#: src/cmd/info.c:76 +#: src/cmd/info.c:75 msgid "Please specify only a single package name" msgstr "Please specify only a single package name" -#: src/cmd/info.c:83 +#: src/cmd/info.c:82 msgid "Please specify a single package" msgstr "Please specify a single package" -#: src/cmd/info.c:98 +#: src/cmd/info.c:97 msgid "Failed to get the changes file for " msgstr "Failed to get the changes file for " -#: src/cmd/info.c:104 +#: src/cmd/info.c:103 msgid "Failed to access the changes file, is the package installed?" msgstr "Failed to access the changes file, is the package installed?" -#: src/cmd/info.c:111 +#: src/cmd/info.c:110 msgid "Failed to get the depends list for " msgstr "Failed to get the depends list for " -#: src/cmd/info.c:138 +#: src/cmd/info.c:137 #, c-format msgid "Name " msgstr "Name " -#: src/cmd/info.c:139 +#: src/cmd/info.c:138 #, c-format msgid "Version " msgstr "Version " -#: src/cmd/info.c:140 +#: src/cmd/info.c:139 #, c-format msgid "Desc " msgstr "Desc " -#: src/cmd/info.c:141 +#: src/cmd/info.c:140 #, c-format msgid "Size " msgstr "Size " -#: src/cmd/info.c:144 +#: src/cmd/info.c:143 #, c-format msgid "Depends " msgstr "Depends " -#: src/cmd/info.c:147 +#: src/cmd/info.c:146 #, c-format msgid "Changes " msgstr "Changes " -#: src/cmd/info.c:151 src/cmd/info.c:152 +#: src/cmd/info.c:149 +#, fuzzy, c-format +msgid "Pool " +msgstr " " + +#: src/cmd/info.c:152 src/cmd/info.c:153 #, c-format msgid "Installed " msgstr "Installed " -#: src/cmd/info.c:154 src/cmd/info.c:155 +#: src/cmd/info.c:156 src/cmd/info.c:157 #, c-format msgid "Up-to-date " msgstr "Up-to-date " diff --git a/src/cmd/info.c b/src/cmd/info.c index 16ea179..9c31bd7 100644 --- a/src/cmd/info.c +++ b/src/cmd/info.c @@ -11,16 +11,14 @@ #include "../cmd.h" #include "../log.h" -lm_pkg_data_t *cmd_info_from_pool(lm_ctx_t *ctx, args_t *args, char *name){ - lm_pkg_t *pkg = NULL; - - if((pkg = lm_ctx_pool_find(ctx, name, NULL)) == NULL){ +lm_pkg_data_t *cmd_info_from_pool(lm_ctx_t *ctx, lm_pkg_t **pkgp, args_t *args, char *name){ + if((*pkgp = lm_ctx_pool_find(ctx, name, NULL)) == NULL){ if(!args_get_bool(args, "grep") && LM_ERR_PkgNotFound == lm_error()) error(_("Package "FG_BOLD"%s"FG_RESET" not found"), name); return NULL; } - return &pkg->data; + return &(*pkgp)->data; } lm_pkg_data_t *cmd_info_from_database(lm_ctx_t *ctx, lm_entry_t *entry, args_t *args, char *name){ @@ -62,6 +60,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){ char *name = NULL, *depends = NULL, *changes = NULL; lm_pkg_data_t *data = NULL; + lm_pkg_t *pkg = NULL; lm_entry_t ent; for(size_t i = 1; i < args->count; i++){ @@ -90,7 +89,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){ } else if(!args_get_bool(args, "database")){ - if((data = cmd_info_from_pool(ctx, args, name)) == NULL) + if((data = cmd_info_from_pool(ctx, &pkg, args, name)) == NULL) return false; } @@ -125,6 +124,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){ printf("CHANGES:%s\n", changes); if(!args_get_bool(args, "database")){ + printf("POOL:%s\n", pkg->pool->name); printf("INSTALLED:%d\n", lm_ctx_database_is_installed(ctx, data->name, NULL)); printf("UPTODATE:%d\n", lm_ctx_database_is_installed(ctx, data->name, data->version)); } @@ -147,9 +147,12 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){ printf(_(FG_BOLD"Changes "FG_BLUE"=>"FG_RESET" %s\n"), changes); if(!args_get_bool(args, "database")){ + printf(_(FG_BOLD"Pool "FG_BLUE"=>"FG_RESET" %s\n"), pkg->pool->name); + printf(lm_ctx_database_is_installed(ctx, data->name, NULL) ? _(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") : _(FG_BOLD"Installed "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n")); + printf(lm_ctx_database_is_installed(ctx, data->name, data->version) ? _(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_GREEN"yes"FG_RESET"\n") : _(FG_BOLD"Up-to-date "FG_BLUE"=>"FG_RESET" "FG_RED"no"FG_RESET"\n"));