/[weechat]/weechat/src/common/command.c
ViewVC logotype

Diff of /weechat/src/common/command.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by flashcode, Sat Nov 22 16:55:56 2003 UTC revision 1.7 by flashcode, Sun Nov 23 17:40:19 2003 UTC
# Line 61  t_weechat_command weechat_commands[] = Line 61  t_weechat_command weechat_commands[] =
61      N_("[command]"), N_("command: name of a WeeChat or IRC command"),      N_("[command]"), N_("command: name of a WeeChat or IRC command"),
62      0, 1, weechat_cmd_help, NULL },      0, 1, weechat_cmd_help, NULL },
63    { "perl", N_("list/load/unload Perl scripts"),    { "perl", N_("list/load/unload Perl scripts"),
64      N_("[load filename] | [unload scriptname]"),      N_("[load filename] | [unload]"),
65      N_("filename: Perl script (file) to load\n"      N_("filename: Perl script (file) to load\n"
     "scriptname: name of script to unload\n"  
66      "Without argument, /perl command lists all loaded Perl scripts."),      "Without argument, /perl command lists all loaded Perl scripts."),
67      0, 2, weechat_cmd_perl, NULL },      0, 2, weechat_cmd_perl, NULL },
68    { "server", N_("list, add or remove servers"),    { "server", N_("list, add or remove servers"),
# Line 990  weechat_cmd_help (int argc, char **argv) Line 989  weechat_cmd_help (int argc, char **argv)
989  int  int
990  weechat_cmd_perl (int argc, char **argv)  weechat_cmd_perl (int argc, char **argv)
991  {  {
992        #ifdef PLUGINS
993        t_plugin_script *ptr_plugin_script;
994        t_plugin_handler *ptr_plugin_handler;
995        int handler_found;
996        
997      #ifdef PLUGIN_PERL      #ifdef PLUGIN_PERL
998      switch (argc)      switch (argc)
999      {      {
1000          case 0:          case 0:
1001              /* list all Perl scripts */              /* list registered Perl scripts */
1002              /* TODO: get list and display it */              gui_printf (NULL, _("Registered Perl scripts:\n"));
1003              break;              if (perl_scripts)
         case 2:  
             if (strcmp (argv[0], "load") == 0)  
1004              {              {
1005                  /* load Perl script */                  for (ptr_plugin_script = perl_scripts; ptr_plugin_script;
1006                  plugin_load (PLUGIN_PERL, argv[1]);                       ptr_plugin_script = ptr_plugin_script->next_script)
1007                    {
1008                        gui_printf (NULL, "  %s v%s%s%s\n",
1009                                    ptr_plugin_script->name,
1010                                    ptr_plugin_script->version,
1011                                    (ptr_plugin_script->description[0]) ? " - " : "",
1012                                    ptr_plugin_script->description);
1013                    }
1014              }              }
1015              else              else
1016                    gui_printf (NULL, _("  (none)\n"));
1017                
1018                /* list Perl message handlers */
1019                gui_printf (NULL, _("Perl message handlers:\n"));
1020                handler_found = 0;
1021                for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler;
1022                     ptr_plugin_handler = ptr_plugin_handler->next_handler)
1023              {              {
1024                  if (strcmp (argv[0], "unload") == 0)                  if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)
1025                  {                  {
1026                      /* unload Perl script */                      handler_found = 1;
1027                        gui_printf (NULL, "  IRC(%s) => Perl(%s)\n",
1028                                    ptr_plugin_handler->name,
1029                                    ptr_plugin_handler->function_name);
1030                  }                  }
1031                  else              }
1032                if (!handler_found)
1033                    gui_printf (NULL, _("  (none)\n"));
1034                
1035                /* list Perl command handlers */
1036                gui_printf (NULL, _("Perl command handlers:\n"));
1037                handler_found = 0;
1038                for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler;
1039                     ptr_plugin_handler = ptr_plugin_handler->next_handler)
1040                {
1041                    if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)
1042                  {                  {
1043                      gui_printf (NULL,                      handler_found = 1;
1044                                  _("%s unknown option for \"%s\" command\n"),                      gui_printf (NULL, "  Command /%s => Perl(%s)\n",
1045                                  WEECHAT_ERROR, "perl");                                  ptr_plugin_handler->name,
1046                                    ptr_plugin_handler->function_name);
1047                  }                  }
1048              }              }
1049                if (!handler_found)
1050                    gui_printf (NULL, _("  (none)\n"));
1051                
1052                break;
1053            case 1:
1054                if (strcmp (argv[0], "unload") == 0)
1055                {
1056                    /* unload all Perl scripts */
1057                    plugin_unload (PLUGIN_TYPE_PERL, NULL);
1058                }
1059                break;
1060            case 2:
1061                if (strcmp (argv[0], "load") == 0)
1062                {
1063                    /* load Perl script */
1064                    plugin_load (PLUGIN_TYPE_PERL, argv[1]);
1065                }
1066                else
1067                {
1068                    gui_printf (NULL,
1069                                _("%s unknown option for \"%s\" command\n"),
1070                                WEECHAT_ERROR, "perl");
1071                }
1072              break;              break;
1073          default:          default:
1074              gui_printf (NULL,              gui_printf (NULL,
# Line 1030  weechat_cmd_perl (int argc, char **argv) Line 1083  weechat_cmd_perl (int argc, char **argv)
1083      /* make gcc happy */      /* make gcc happy */
1084      (void) argc;      (void) argc;
1085      (void) argv;      (void) argv;
1086      #endif      #endif /* PLUGIN_PERL */
1087        
1088        #endif /* PLUGINS */
1089            
1090      return 0;      return 0;
1091  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26