From 6908ab747d1eb461c8b8e666113aed47924f5b58 Mon Sep 17 00:00:00 2001 From: dequis Date: Sun, 25 Dec 2016 19:50:31 -0300 Subject: Add 'plugins info' subcommand, only show plugin details there --- root_commands.c | 67 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 16 deletions(-) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index e0c0b7f8..6bc34fb5 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1163,36 +1163,71 @@ static void prplstr(GList *prpls, GString *gstr) g_list_free(prpls); } +static void cmd_plugins_info(irc_t *irc, char **cmd) +{ + GList *l; + struct plugin_info *info; + + MIN_ARGS(2); + + for (l = get_plugins(); l; l = l->next) { + info = l->data; + if (g_strcasecmp(cmd[2], info->name) == 0) { + break; + } + } + + if (!l) { + return; + } + + irc_rootmsg(irc, "%s:", info->name); + irc_rootmsg(irc, " Version: %s", info->version); + + if (info->description) { + irc_rootmsg(irc, " Description: %s", info->description); + } + + if (info->author) { + irc_rootmsg(irc, " Author: %s", info->author); + } + + if (info->url) { + irc_rootmsg(irc, " URL: %s", info->url); + } +} + static void cmd_plugins(irc_t *irc, char **cmd) { GList *prpls; GString *gstr; + if (cmd[1] && g_strcasecmp(cmd[1], "info") == 0) { + cmd_plugins_info(irc, cmd); + return; + } + #ifdef WITH_PLUGINS GList *l; struct plugin_info *info; + char *format; - for (l = get_plugins(); l; l = l->next) { - info = l->data; - irc_rootmsg(irc, "%s:", info->name); - irc_rootmsg(irc, " Version: %s", info->version); - - if (info->description) { - irc_rootmsg(irc, " Description: %s", info->description); - } - - if (info->author) { - irc_rootmsg(irc, " Author: %s", info->author); - } + if (strchr(irc->umode, 'b') != NULL) { + format = "%s\t%s"; + } else { + format = "%-30s %s"; + } - if (info->url) { - irc_rootmsg(irc, " URL: %s", info->url); - } + irc_rootmsg(irc, format, "Plugin", "Version"); - irc_rootmsg(irc, ""); + for (l = get_plugins(); l; l = l->next) { + info = l->data; + irc_rootmsg(irc, format, info->name, info->version); } #endif + irc_rootmsg(irc, ""); + gstr = g_string_new(NULL); prpls = get_protocols(); -- cgit v1.2.3