Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add command "pkg-detail" #12

Open
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants

ekd123 commented Apr 23, 2012

zif pkg-detail zif description
zif pkg-detail zif version
zif info-only yum summary

My version just checks out the information from the remote repositories.
By the way, please take a look at line 1168, I really don't know why.

Maybe this patch seems a little dirty.

@ekd123 ekd123 Add a command called 'pkg-detail' which displays only one detail abou…
…t a package from the remote repositories, with an alias to it named 'info-only'.

This allows you, for example, to get the URL of PACKAGE using 'zif pkg-detail PACKAGE url'
45d3a6e

ekd123 commented Apr 23, 2012

I forgot to say that the output format of command 'info' is changed, too. It looks cleaner than before.

Well, maybe still buggy.

Owner

hughsie commented Apr 23, 2012

commit 50c3ea2
Author: Richard Hughes richard@hughsie.com
Date: Mon Apr 23 17:10:55 2012 +0100

Pad the output of 'zif get-details pkgname' in a better way

Inspired from a patch by Mike Manilone <crtmike@gmail.com>, many thanks.

@hughsie hughsie commented on an outdated diff Apr 23, 2012

tools/zif-main.c
+ * zif_cmd_pkg_detail:
+ */
+static gboolean
+zif_cmd_pkg_detail (ZifCmdPrivate *priv, gchar **values, GError **error)
+{
+ ZifPackage *package = NULL;
+ ZifState *state_local = NULL;
+ GPtrArray *store_array = NULL;
+ gchar *tmp_strv[2] = { NULL, NULL };
+ GPtrArray *array = NULL;
+ GString *string = NULL;
+ gboolean ret = FALSE;
+
+ zif_progress_bar_start (priv->progressbar, _("Getting the detail"));
+
+ ret = zif_state_set_steps (priv->state,
@hughsie

hughsie Apr 23, 2012

Owner

This needs to set the correct number of steps. If there are two steps, and the first takes 20% of the time and the second takes 80% of the time, then this would be 20, 80, -1

@hughsie hughsie and 1 other commented on an outdated diff Apr 23, 2012

tools/zif-main.c
+ if (!ret)
+ goto out;
+
+ /* add remote packages */
+ store_array = zif_store_array_new ();
+ state_local = zif_state_get_child (priv->state);
+ ret= zif_store_array_add_remote_enabled (store_array, state_local, error);
+ if (!ret)
+ goto out;
+
+ /* this section done */
+ ret = zif_state_done (priv->state, error);
+ if (!ret)
+ goto out;
+
+ /* check we have a value */
@hughsie

hughsie Apr 23, 2012

Owner

We probably want to check the number of arguments using g_strv_length(values) rather than doing it one by one. Then we can have something like "Specify a package name and data type, e.g. 'colord url'"

@hughsie hughsie and 1 other commented on an outdated diff Apr 23, 2012

tools/zif-main.c
+ goto out;
+ }
+
+ /* filter the results in a sane way */
+ ret = zif_filter_post_resolve (priv, array, error);
+ if (!ret)
+ goto out;
+
+ if (array->len == 0) {
+ g_set_error_literal (error, 1, 0,
+ _("No package was found"));
+ goto out;
+ }
+
+ string = g_string_new ("");
+ package = g_ptr_array_index (array, 0);
@hughsie

hughsie Apr 23, 2012

Owner

What happens when we have more than one package that matches? Do we just assume that the installed package is the same as all the remote packages? That's probably a sane assumption, until we get to the package size, where the user might want the installed size of the package, not the remote .rpm size, or vice versa.

@ekd123

ekd123 May 6, 2012

now works if more than one package matches.
added options just like Yum's "available/installed".

@hughsie hughsie commented on an outdated diff Apr 23, 2012

tools/zif-main.c
+
+ /* filter the results in a sane way */
+ ret = zif_filter_post_resolve (priv, array, error);
+ if (!ret)
+ goto out;
+
+ if (array->len == 0) {
+ g_set_error_literal (error, 1, 0,
+ _("No package was found"));
+ goto out;
+ }
+
+ string = g_string_new ("");
+ package = g_ptr_array_index (array, 0);
+ state_local = zif_state_get_child (priv->state);
+ if (!g_strcmp0 (values[1], "name"))
@hughsie

hughsie Apr 23, 2012

Owner

The convention I've used in other places in the code is g_strcmp0 (value, "value") == 0

@hughsie hughsie and 1 other commented on an outdated diff Apr 23, 2012

tools/zif-main.c
+ else if (!g_strcmp0 (values[1], "size")) {
+ g_string_append_printf (string, "%" G_GUINT64_FORMAT "\n", zif_package_get_size (package, state_local, NULL));
+ }
+ else if (!g_strcmp0 (values[1], "repo"))
+ g_string_append_printf (string, "%s\n", zif_package_get_data (package));
+ else if (!g_strcmp0 (values[1], "summary"))
+ g_string_append_printf (string, "%s\n", zif_package_get_summary (package, state_local, NULL));
+ else if (!g_strcmp0 (values[1], "url"))
+ g_string_append_printf (string, "%s\n", zif_package_get_url (package, state_local, NULL));
+ else if (!g_strcmp0 (values[1], "license"))
+ g_string_append_printf (string, "%s\n", zif_package_get_license (package, state_local, NULL));
+ else if (!g_strcmp0 (values[1], "description"))
+ g_string_append_printf (string, "%s\n", zif_package_get_description (package, state_local, NULL));
+
+ /* this section done */
+ /* if we use this code, it will print "The system state was invalid: done on a state 0xXXXX that did not have a size set!" */
@hughsie

hughsie Apr 23, 2012

Owner

Fix the steps, and you can enable this :)

@hughsie hughsie commented on the diff Apr 23, 2012

tools/zif-main.c
@@ -6797,6 +6923,11 @@ typedef gboolean (*ZifCmdPrivateCb) (ZifCmdPrivate *cmd,
_("Display details about a package or group of packages"),
zif_cmd_get_details);
zif_cmd_add (priv->cmd_array,
@hughsie

hughsie Apr 23, 2012

Owner

"pkg-detail" make sense, but the second things are designed to make zif more compatible with yum. I think we can just drop info-only.

ekd123 commented Apr 26, 2012

Sorry, these days I have some work to do. I'll work on this feature again in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment