diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 5 | ||||
-rw-r--r-- | src/command/commands.c | 42 |
2 files changed, 36 insertions, 11 deletions
diff --git a/src/command/command.c b/src/command/command.c index 3defbfee..82f6a4b0 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -127,6 +127,7 @@ GHashTable *commands = NULL; #define CMD_TAG_CONNECTION "connection" #define CMD_TAG_DISCOVERY "discovery" #define CMD_TAG_UI "ui" +#define CMD_TAG_PLUGINS "plugins" #define CMD_NOTAGS { { NULL }, #define CMD_TAGS(...) { { __VA_ARGS__, NULL }, @@ -2065,6 +2066,7 @@ cmd_init(void) autocomplete_add(help_commands_ac, "discovery"); autocomplete_add(help_commands_ac, "connection"); autocomplete_add(help_commands_ac, "ui"); + autocomplete_add(help_commands_ac, "plugins"); prefs_ac = autocomplete_new(); autocomplete_add(prefs_ac, "ui"); @@ -2899,7 +2901,8 @@ cmd_valid_tag(const char *const str) (g_strcmp0(str, CMD_TAG_ROSTER) == 0) || (g_strcmp0(str, CMD_TAG_DISCOVERY) == 0) || (g_strcmp0(str, CMD_TAG_CONNECTION) == 0) || - (g_strcmp0(str, CMD_TAG_UI) == 0)); + (g_strcmp0(str, CMD_TAG_UI) == 0) || + (g_strcmp0(str, CMD_TAG_PLUGINS) == 0)); } gboolean diff --git a/src/command/commands.c b/src/command/commands.c index 9f9c099d..79b4def9 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1293,19 +1293,41 @@ _cmd_help_cmd_list(const char *const tag) } GList *ordered_commands = NULL; - GHashTableIter iter; - gpointer key; - gpointer value; - g_hash_table_iter_init(&iter, commands); - while (g_hash_table_iter_next(&iter, &key, &value)) { - Command *pcmd = (Command *)value; - if (tag) { - if (cmd_has_tag(pcmd, tag)) { + if (g_strcmp0(tag, "plugins") == 0) { + GList *plugins_cmds = plugins_get_command_names(); + GList *curr = plugins_cmds; + while (curr) { + ordered_commands = g_list_insert_sorted(ordered_commands, curr->data, (GCompareFunc)g_strcmp0); + curr = g_list_next(curr); + } + g_list_free(plugins_cmds); + } else { + GHashTableIter iter; + gpointer key; + gpointer value; + + g_hash_table_iter_init(&iter, commands); + while (g_hash_table_iter_next(&iter, &key, &value)) { + Command *pcmd = (Command *)value; + if (tag) { + if (cmd_has_tag(pcmd, tag)) { + ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0); + } + } else { ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0); } - } else { - ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0); + } + + // add plugins if showing all commands + if (!tag) { + GList *plugins_cmds = plugins_get_command_names(); + GList *curr = plugins_cmds; + while (curr) { + ordered_commands = g_list_insert_sorted(ordered_commands, curr->data, (GCompareFunc)g_strcmp0); + curr = g_list_next(curr); + } + g_list_free(plugins_cmds); } } |