Changeset 6908ab7


Ignore:
Timestamp:
2016-12-26T00:18:55Z (7 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
7486853
Parents:
1999fe5
git-author:
dequis <dx@…> (25-12-16 22:50:31)
git-committer:
dequis <dx@…> (26-12-16 00:18:55)
Message:

Add 'plugins info' subcommand, only show plugin details there

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/user-guide/commands.xml

    r1999fe5 r6908ab7  
    18691869        <bitlbee-command name="plugins">
    18701870                <short-description>List all the external plugins and protocols</short-description>
    1871                 <syntax>plugins</syntax>
     1871                <syntax>plugins [info &lt;name&gt;]</syntax>
    18721872
    18731873                <description>
    18741874                        <para>
    18751875                                This gives you a list of all the external plugins and protocols.
     1876                        </para>
     1877
     1878                        <para>
     1879                                Use the <emphasis>info</emphasis> subcommand to get more details about a plugin.
    18761880                        </para>
    18771881                </description>
  • root_commands.c

    r1999fe5 r6908ab7  
    11641164}
    11651165
     1166static void cmd_plugins_info(irc_t *irc, char **cmd)
     1167{
     1168        GList *l;
     1169        struct plugin_info *info;
     1170
     1171        MIN_ARGS(2);
     1172
     1173        for (l = get_plugins(); l; l = l->next) {
     1174                info = l->data;
     1175                if (g_strcasecmp(cmd[2], info->name) == 0) {
     1176                        break;
     1177                }
     1178        }
     1179
     1180        if (!l) {
     1181                return;
     1182        }
     1183
     1184        irc_rootmsg(irc, "%s:", info->name);
     1185        irc_rootmsg(irc, "  Version: %s", info->version);
     1186
     1187        if (info->description) {
     1188                irc_rootmsg(irc, "  Description: %s", info->description);
     1189        }
     1190
     1191        if (info->author) {
     1192                irc_rootmsg(irc, "  Author: %s", info->author);
     1193        }
     1194
     1195        if (info->url) {
     1196                irc_rootmsg(irc, "  URL: %s", info->url);
     1197        }
     1198}
     1199
    11661200static void cmd_plugins(irc_t *irc, char **cmd)
    11671201{
    11681202        GList *prpls;
    11691203        GString *gstr;
     1204
     1205        if (cmd[1] && g_strcasecmp(cmd[1], "info") == 0) {
     1206                cmd_plugins_info(irc, cmd);
     1207                return;
     1208        }
    11701209
    11711210#ifdef WITH_PLUGINS
    11721211        GList *l;
    11731212        struct plugin_info *info;
     1213        char *format;
     1214
     1215        if (strchr(irc->umode, 'b') != NULL) {
     1216                format = "%s\t%s";
     1217        } else {
     1218                format = "%-30s  %s";
     1219        }
     1220
     1221        irc_rootmsg(irc, format, "Plugin", "Version");
    11741222
    11751223        for (l = get_plugins(); l; l = l->next) {
    11761224                info = l->data;
    1177                 irc_rootmsg(irc, "%s:", info->name);
    1178                 irc_rootmsg(irc, "  Version: %s", info->version);
    1179 
    1180                 if (info->description) {
    1181                         irc_rootmsg(irc, "  Description: %s", info->description);
    1182                 }
    1183 
    1184                 if (info->author) {
    1185                         irc_rootmsg(irc, "  Author: %s", info->author);
    1186                 }
    1187 
    1188                 if (info->url) {
    1189                         irc_rootmsg(irc, "  URL: %s", info->url);
    1190                 }
    1191 
    1192                 irc_rootmsg(irc, "");
     1225                irc_rootmsg(irc, format, info->name, info->version);
    11931226        }
    11941227#endif
     1228
     1229        irc_rootmsg(irc, "");
    11951230
    11961231        gstr = g_string_new(NULL);
Note: See TracChangeset for help on using the changeset viewer.