From 10a170bf7d75a4731583182f40422c0ac23d4c78 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 23 Nov 2003 17:40:19 +0000 Subject: - Perl unloading is now ok (unload all scripts), - /perl prints all Perl scripts, - error if registering 2 Perl scripts with same (internal) name. --- src/common/command.c | 87 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 16 deletions(-) (limited to 'src/common') diff --git a/src/common/command.c b/src/common/command.c index 10a9eecd0..769edcd6b 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -61,9 +61,8 @@ t_weechat_command weechat_commands[] = N_("[command]"), N_("command: name of a WeeChat or IRC command"), 0, 1, weechat_cmd_help, NULL }, { "perl", N_("list/load/unload Perl scripts"), - N_("[load filename] | [unload scriptname]"), + N_("[load filename] | [unload]"), N_("filename: Perl script (file) to load\n" - "scriptname: name of script to unload\n" "Without argument, /perl command lists all loaded Perl scripts."), 0, 2, weechat_cmd_perl, NULL }, { "server", N_("list, add or remove servers"), @@ -990,32 +989,86 @@ weechat_cmd_help (int argc, char **argv) int weechat_cmd_perl (int argc, char **argv) { + #ifdef PLUGINS + t_plugin_script *ptr_plugin_script; + t_plugin_handler *ptr_plugin_handler; + int handler_found; + #ifdef PLUGIN_PERL switch (argc) { case 0: - /* list all Perl scripts */ - /* TODO: get list and display it */ - break; - case 2: - if (strcmp (argv[0], "load") == 0) + /* list registered Perl scripts */ + gui_printf (NULL, _("Registered Perl scripts:\n")); + if (perl_scripts) { - /* load Perl script */ - plugin_load (PLUGIN_PERL, argv[1]); + for (ptr_plugin_script = perl_scripts; ptr_plugin_script; + ptr_plugin_script = ptr_plugin_script->next_script) + { + gui_printf (NULL, " %s v%s%s%s\n", + ptr_plugin_script->name, + ptr_plugin_script->version, + (ptr_plugin_script->description[0]) ? " - " : "", + ptr_plugin_script->description); + } } else + gui_printf (NULL, _(" (none)\n")); + + /* list Perl message handlers */ + gui_printf (NULL, _("Perl message handlers:\n")); + handler_found = 0; + for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler; + ptr_plugin_handler = ptr_plugin_handler->next_handler) { - if (strcmp (argv[0], "unload") == 0) + if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL) { - /* unload Perl script */ + handler_found = 1; + gui_printf (NULL, " IRC(%s) => Perl(%s)\n", + ptr_plugin_handler->name, + ptr_plugin_handler->function_name); } - else + } + if (!handler_found) + gui_printf (NULL, _(" (none)\n")); + + /* list Perl command handlers */ + gui_printf (NULL, _("Perl command handlers:\n")); + handler_found = 0; + for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler; + ptr_plugin_handler = ptr_plugin_handler->next_handler) + { + if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL) { - gui_printf (NULL, - _("%s unknown option for \"%s\" command\n"), - WEECHAT_ERROR, "perl"); + handler_found = 1; + gui_printf (NULL, " Command /%s => Perl(%s)\n", + ptr_plugin_handler->name, + ptr_plugin_handler->function_name); } } + if (!handler_found) + gui_printf (NULL, _(" (none)\n")); + + break; + case 1: + if (strcmp (argv[0], "unload") == 0) + { + /* unload all Perl scripts */ + plugin_unload (PLUGIN_TYPE_PERL, NULL); + } + break; + case 2: + if (strcmp (argv[0], "load") == 0) + { + /* load Perl script */ + plugin_load (PLUGIN_TYPE_PERL, argv[1]); + } + else + { + gui_printf (NULL, + _("%s unknown option for \"%s\" command\n"), + WEECHAT_ERROR, "perl"); + } break; default: gui_printf (NULL, @@ -1030,7 +1083,9 @@ weechat_cmd_perl (int argc, char **argv) /* make gcc happy */ (void) argc; (void) argv; - #endif + #endif /* PLUGIN_PERL */ + + #endif /* PLUGINS */ return 0; } -- cgit v1.2.3