summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-06-13 15:19:44 +0100
committerRichard Hughes <richard@hughsie.com>2014-06-13 15:19:44 +0100
commit9a2c7a5fec10847b57ba598bc6ca4db4a14f3928 (patch)
treeeff54a03352e47c4ad75d54787330e38b7ab2790
parent383d8b04164c878cdc3cddd465de13eff976618e (diff)
downloadappstream-glib-9a2c7a5fec10847b57ba598bc6ca4db4a14f3928.tar.gz
Add a hidden command 'list-commands' for bash-completion
-rw-r--r--client/as-util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/client/as-util.c b/client/as-util.c
index 7ab36bd..19e9ff2 100644
--- a/client/as-util.c
+++ b/client/as-util.c
@@ -166,6 +166,18 @@ as_util_run (AsUtilPrivate *priv, const gchar *command, gchar **values, GError *
guint i;
_cleanup_string_free_ GString *string = NULL;
+ /* for bash completion */
+ if (g_strcmp0 (command, "list-commands") == 0) {
+ string = g_string_new ("");
+ for (i = 0; i < priv->cmd_array->len; i++) {
+ item = g_ptr_array_index (priv->cmd_array, i);
+ g_string_append_printf (string, "%s ", item->name);
+ }
+ g_string_truncate (string, string->len - 1);
+ g_print ("%s\n", string->str);
+ return TRUE;
+ }
+
/* find command */
for (i = 0; i < priv->cmd_array->len; i++) {
item = g_ptr_array_index (priv->cmd_array, i);