aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2016-12-25 19:50:31 -0300
committerdequis <dx@dxzone.com.ar>2016-12-25 21:18:55 -0300
commit6908ab747d1eb461c8b8e666113aed47924f5b58 (patch)
tree53bd6553eae895d9da607f7952003f587ed89931
parent1999fe5eadc7c7575e33542da42b0e21b10366d9 (diff)
Add 'plugins info' subcommand, only show plugin details there
-rw-r--r--doc/user-guide/commands.xml6
-rw-r--r--root_commands.c67
2 files changed, 56 insertions, 17 deletions
diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml
index 6b725156..7190f024 100644
--- a/doc/user-guide/commands.xml
+++ b/doc/user-guide/commands.xml
@@ -1868,12 +1868,16 @@
<bitlbee-command name="plugins">
<short-description>List all the external plugins and protocols</short-description>
- <syntax>plugins</syntax>
+ <syntax>plugins [info &lt;name&gt;]</syntax>
<description>
<para>
This gives you a list of all the external plugins and protocols.
</para>
+
+ <para>
+ Use the <emphasis>info</emphasis> subcommand to get more details about a plugin.
+ </para>
</description>
</bitlbee-command>
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();