diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2003-11-23 17:40:19 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2003-11-23 17:40:19 +0000 |
commit | 10a170bf7d75a4731583182f40422c0ac23d4c78 (patch) | |
tree | 33604d9a1e2026dc181647e97866dbf075e4e8d6 /src/common | |
parent | 7a3ee901a469fe554697c499efc8711f8084c564 (diff) | |
download | weechat-10a170bf7d75a4731583182f40422c0ac23d4c78.zip |
- Perl unloading is now ok (unload all scripts),
- /perl prints all Perl scripts,
- error if registering 2 Perl scripts with same (internal) name.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/command.c | 87 |
1 files changed, 71 insertions, 16 deletions
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; } |