[gnome-shell] extensions-tool: Add info command
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensions-tool: Add info command
- Date: Wed, 21 Aug 2019 16:39:17 +0000 (UTC)
commit 07ad4d89116f01d9ee35c226859d7f0b47d7f4a3
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Aug 28 06:01:30 2018 +0200
extensions-tool: Add info command
We already support displaying extension details for the list command,
so it's a logical extension to also support showing extension info
for a particular extension (not least because the shell has a
corresponding D-Bus method).
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1234
src/extensions-tool/command-info.c | 106 +++++++++++++++++++++++++++
src/extensions-tool/commands.h | 1 +
src/extensions-tool/main.c | 3 +
src/extensions-tool/man/gnome-extensions.txt | 6 ++
src/extensions-tool/meson-src.build | 1 +
src/extensions-tool/meson.build | 1 +
6 files changed, 118 insertions(+)
---
diff --git a/src/extensions-tool/command-info.c b/src/extensions-tool/command-info.c
new file mode 100644
index 0000000000..a0ae0c6ac8
--- /dev/null
+++ b/src/extensions-tool/command-info.c
@@ -0,0 +1,106 @@
+/* commands-info.c
+ *
+ * Copyright 2018 Florian Müllner <fmuellner gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "commands.h"
+#include "common.h"
+#include "config.h"
+
+static gboolean
+show_extension_info (const char *uuid)
+{
+ g_autoptr (GDBusProxy) proxy = NULL;
+ g_autoptr (GVariant) response = NULL;
+ g_autoptr (GVariant) asv = NULL;
+ g_autoptr (GVariantDict) info = NULL;
+ g_autoptr (GError) error = NULL;
+
+ proxy = get_shell_proxy (&error);
+ if (proxy == NULL)
+ return FALSE;
+
+ response = g_dbus_proxy_call_sync (proxy,
+ "GetExtensionInfo",
+ g_variant_new ("(s)", uuid),
+ 0,
+ -1,
+ NULL,
+ &error);
+ if (response == NULL)
+ return FALSE;
+
+ asv = g_variant_get_child_value (response, 0);
+ info = g_variant_dict_new (asv);
+
+ if (!g_variant_dict_contains (info, "uuid"))
+ return FALSE;
+
+ print_extension_info (info, DISPLAY_DETAILED);
+
+ return TRUE;
+}
+
+int
+handle_info (int argc, char *argv[], gboolean do_help)
+{
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (GError) error = NULL;
+ g_auto(GStrv) uuids = NULL;
+ GOptionEntry entries[] = {
+ { .long_name = G_OPTION_REMAINING,
+ .arg_description = "UUID",
+ .arg = G_OPTION_ARG_STRING_ARRAY, .arg_data = &uuids },
+ { NULL }
+ };
+
+ g_set_prgname ("gnome-extensions info");
+
+ context = g_option_context_new (NULL);
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_summary (context, _("Show extensions info"));
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+
+ if (do_help)
+ {
+ show_help (context, NULL);
+ return 0;
+ }
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ show_help (context, error->message);
+ return 1;
+ }
+
+ if (uuids == NULL)
+ {
+ show_help (context, _("No UUID given"));
+ return 1;
+ }
+ else if (g_strv_length (uuids) > 1)
+ {
+ show_help (context, _("More than one UUID given"));
+ return 1;
+ }
+
+ return show_extension_info (*uuids) ? 0 : 2;
+}
diff --git a/src/extensions-tool/commands.h b/src/extensions-tool/commands.h
index fc40e5c732..ddca52ea6f 100644
--- a/src/extensions-tool/commands.h
+++ b/src/extensions-tool/commands.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
int handle_enable (int argc, char *argv[], gboolean do_help);
int handle_disable (int argc, char *argv[], gboolean do_help);
int handle_list (int argc, char *argv[], gboolean do_help);
+int handle_info (int argc, char *argv[], gboolean do_help);
int handle_create (int argc, char *argv[], gboolean do_help);
G_END_DECLS
diff --git a/src/extensions-tool/main.c b/src/extensions-tool/main.c
index f415e01687..5925306113 100644
--- a/src/extensions-tool/main.c
+++ b/src/extensions-tool/main.c
@@ -159,6 +159,7 @@ usage (void)
g_printerr (" enable %s\n", _("Enable extension"));
g_printerr (" disable %s\n", _("Disable extension"));
g_printerr (" list %s\n", _("List extensions"));
+ g_printerr (" info %s\n", _("Show extension info"));
g_printerr (" create %s\n", _("Create extension"));
g_printerr ("\n");
g_printerr (_("Use %s to get detailed help.\n"), "“gnome-extensions help COMMAND”");
@@ -219,6 +220,8 @@ main (int argc, char *argv[])
return handle_disable (argc, argv, do_help);
else if (g_str_equal (command, "list"))
return handle_list (argc, argv, do_help);
+ else if (g_str_equal (command, "info"))
+ return handle_info (argc, argv, do_help);
else if (g_str_equal (command, "create"))
return handle_create (argc, argv, do_help);
else
diff --git a/src/extensions-tool/man/gnome-extensions.txt b/src/extensions-tool/man/gnome-extensions.txt
index aaf6f0d5c6..d3f7137c98 100644
--- a/src/extensions-tool/man/gnome-extensions.txt
+++ b/src/extensions-tool/man/gnome-extensions.txt
@@ -19,6 +19,8 @@ SYNOPSIS
*gnome-extensions* disable 'UUID'
+*gnome-extensions* info 'UUID'
+
*gnome-extensions* list ['OPTION'...]
*gnome-extensions* create ['OPTION'...]
@@ -50,6 +52,10 @@ Disables the extension identified by 'UUID'.
+
If the extension is not enabled, the command will do nothing.
+*info* 'UUID'::
+Show details of the extension identified by 'UUID', including name,
+description and state.
+
*list* ['OPTION'...]::
Displays a list of installed extensions.
+
diff --git a/src/extensions-tool/meson-src.build b/src/extensions-tool/meson-src.build
index 21d70a39f8..a0c462d064 100644
--- a/src/extensions-tool/meson-src.build
+++ b/src/extensions-tool/meson-src.build
@@ -3,6 +3,7 @@ sources = [
'command-create.c',
'command-disable.c',
'command-enable.c',
+ 'command-info.c',
'command-list.c',
'common.h',
'main.c'
diff --git a/src/extensions-tool/meson.build b/src/extensions-tool/meson.build
index d6f674b4a8..c93de7633b 100644
--- a/src/extensions-tool/meson.build
+++ b/src/extensions-tool/meson.build
@@ -12,6 +12,7 @@ sources = [
'command-create.c',
'command-disable.c',
'command-enable.c',
+ 'command-info.c',
'command-list.c',
'main.c'
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]