/[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.64 by flashcode, Tue Jul 19 12:19:06 2005 UTC revision 1.65 by flashcode, Sun Aug 21 16:32:48 2005 UTC
# Line 89  t_weechat_command weechat_commands[] = Line 89  t_weechat_command weechat_commands[] =
89      N_("filename: Python script (file) to load\n"      N_("filename: Python script (file) to load\n"
90         "Without argument, /python command lists all loaded Python scripts."),         "Without argument, /python command lists all loaded Python scripts."),
91      0, 2, weechat_cmd_python, NULL },      0, 2, weechat_cmd_python, NULL },
92      { "ruby", N_("list/load/unload Ruby scripts"),
93        N_("[load filename] | [autoload] | [reload] | [unload]"),
94        N_("filename: Ruby script (file) to load\n"
95           "Without argument, /ruby command lists all loaded Ruby scripts."),
96        0, 2, weechat_cmd_ruby, NULL },
97    { "server", N_("list, add or remove servers"),    { "server", N_("list, add or remove servers"),
98      N_("[servername] | "      N_("[servername] | "
99         "[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "         "[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 "
# Line 1486  weechat_cmd_key (char *arguments) Line 1491  weechat_cmd_key (char *arguments)
1491  int  int
1492  weechat_cmd_perl (int argc, char **argv)  weechat_cmd_perl (int argc, char **argv)
1493  {  {
1494      #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
1495      t_plugin_script *ptr_plugin_script;      t_plugin_script *ptr_plugin_script;
1496      t_plugin_handler *ptr_plugin_handler;      t_plugin_handler *ptr_plugin_handler;
1497      int handler_found, path_length;      int handler_found, path_length;
# Line 1608  weechat_cmd_perl (int argc, char **argv) Line 1613  weechat_cmd_perl (int argc, char **argv)
1613                          _("%s wrong argument count for \"%s\" command\n"),                          _("%s wrong argument count for \"%s\" command\n"),
1614                          WEECHAT_ERROR, "perl");                          WEECHAT_ERROR, "perl");
1615      }      }
1616      #else  #else
1617      irc_display_prefix (NULL, PREFIX_ERROR);      irc_display_prefix (NULL, PREFIX_ERROR);
1618      gui_printf (NULL,      gui_printf (NULL,
1619                  _("WeeChat was build without Perl support.\n"                  _("WeeChat was build without Perl support.\n"
# Line 1617  weechat_cmd_perl (int argc, char **argv) Line 1622  weechat_cmd_perl (int argc, char **argv)
1622      /* make gcc happy */      /* make gcc happy */
1623      (void) argc;      (void) argc;
1624      (void) argv;      (void) argv;
1625      #endif /* PLUGIN_PERL */  #endif /* PLUGIN_PERL */
1626            
1627      return 0;      return 0;
1628  }  }
# Line 1629  weechat_cmd_perl (int argc, char **argv) Line 1634  weechat_cmd_perl (int argc, char **argv)
1634  int  int
1635  weechat_cmd_python (int argc, char **argv)  weechat_cmd_python (int argc, char **argv)
1636  {  {
1637      #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
1638      t_plugin_script *ptr_plugin_script;      t_plugin_script *ptr_plugin_script;
1639      t_plugin_handler *ptr_plugin_handler;      t_plugin_handler *ptr_plugin_handler;
1640      int handler_found, path_length;      int handler_found, path_length;
# Line 1751  weechat_cmd_python (int argc, char **arg Line 1756  weechat_cmd_python (int argc, char **arg
1756                          _("%s wrong argument count for \"%s\" command\n"),                          _("%s wrong argument count for \"%s\" command\n"),
1757                          WEECHAT_ERROR, "python");                          WEECHAT_ERROR, "python");
1758      }      }
1759      #else  #else
1760      irc_display_prefix (NULL, PREFIX_ERROR);      irc_display_prefix (NULL, PREFIX_ERROR);
1761      gui_printf (NULL,      gui_printf (NULL,
1762                  _("WeeChat was build without Python support.\n"                  _("WeeChat was build without Python support.\n"
# Line 1760  weechat_cmd_python (int argc, char **arg Line 1765  weechat_cmd_python (int argc, char **arg
1765      /* make gcc happy */      /* make gcc happy */
1766      (void) argc;      (void) argc;
1767      (void) argv;      (void) argv;
1768      #endif /* PLUGIN_PYTHON */  #endif /* PLUGIN_PYTHON */
1769        
1770        return 0;
1771    }
1772    
1773    /*
1774     * weechat_cmd_ruby: list/load/unload Ruby scripts
1775     */
1776    
1777    int
1778    weechat_cmd_ruby (int argc, char **argv)
1779    {
1780    #ifdef PLUGIN_RUBY
1781        t_plugin_script *ptr_plugin_script;
1782        t_plugin_handler *ptr_plugin_handler;
1783        int handler_found, path_length;
1784        char *path_script;
1785        
1786        switch (argc)
1787        {
1788            case 0:
1789                /* list registered Ruby scripts */
1790                gui_printf (NULL, "\n");
1791                gui_printf (NULL, _("Registered %s scripts:\n"), "Ruby");
1792                if (ruby_scripts)
1793                {
1794                    for (ptr_plugin_script = ruby_scripts; ptr_plugin_script;
1795                         ptr_plugin_script = ptr_plugin_script->next_script)
1796                    {
1797                        irc_display_prefix (NULL, PREFIX_PLUGIN);
1798                        gui_printf (NULL, "  %s v%s%s%s\n",
1799                                    ptr_plugin_script->name,
1800                                    ptr_plugin_script->version,
1801                                    (ptr_plugin_script->description[0]) ? " - " : "",
1802                                    ptr_plugin_script->description);
1803                    }
1804                }
1805                else
1806                {
1807                    irc_display_prefix (NULL, PREFIX_PLUGIN);
1808                    gui_printf (NULL, _("  (none)\n"));
1809                }
1810                
1811                /* list Ruby message handlers */
1812                gui_printf (NULL, "\n");
1813                gui_printf (NULL, _("%s message handlers:\n"), "Ruby");
1814                handler_found = 0;
1815                for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler;
1816                     ptr_plugin_handler = ptr_plugin_handler->next_handler)
1817                {
1818                    if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY)
1819                    {
1820                        handler_found = 1;
1821                        irc_display_prefix (NULL, PREFIX_PLUGIN);
1822                        gui_printf (NULL, _("  IRC(%s) => %s(%s)\n"),
1823                                    ptr_plugin_handler->name,
1824                                    "Ruby",
1825                                    ptr_plugin_handler->function_name);
1826                    }
1827                }
1828                if (!handler_found)
1829                {
1830                    irc_display_prefix (NULL, PREFIX_PLUGIN);
1831                    gui_printf (NULL, _("  (none)\n"));
1832                }
1833                
1834                /* list Ruby command handlers */
1835                gui_printf (NULL, "\n");
1836                gui_printf (NULL, _("%s command handlers:\n"), "Ruby");
1837                handler_found = 0;
1838                for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler;
1839                     ptr_plugin_handler = ptr_plugin_handler->next_handler)
1840                {
1841                    if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY)
1842                    {
1843                        handler_found = 1;
1844                        irc_display_prefix (NULL, PREFIX_PLUGIN);
1845                        gui_printf (NULL, _("  Command /%s => %s(%s)\n"),
1846                                    ptr_plugin_handler->name,
1847                                    "Ruby",
1848                                    ptr_plugin_handler->function_name);
1849                    }
1850                }
1851                if (!handler_found)
1852                {
1853                    irc_display_prefix (NULL, PREFIX_PLUGIN);
1854                    gui_printf (NULL, _("  (none)\n"));
1855                }
1856                
1857                break;
1858            case 1:
1859                if (strcasecmp (argv[0], "autoload") == 0)
1860                    plugin_auto_load (PLUGIN_TYPE_RUBY, "ruby/autoload");
1861                else if (strcasecmp (argv[0], "reload") == 0)
1862                {
1863                    plugin_unload (PLUGIN_TYPE_RUBY, NULL);
1864                    plugin_auto_load (PLUGIN_TYPE_RUBY, "ruby/autoload");
1865                }
1866                else if (strcasecmp (argv[0], "unload") == 0)
1867                    plugin_unload (PLUGIN_TYPE_RUBY, NULL);
1868                break;
1869            case 2:
1870                if (strcasecmp (argv[0], "load") == 0)
1871                {
1872                    /* load Ruby script */
1873                    if (strstr(argv[1], DIR_SEPARATOR))
1874                        path_script = NULL;
1875                    else
1876                    {
1877                        path_length = strlen (weechat_home) + strlen (argv[1]) + 9;
1878                        path_script = (char *) malloc (path_length * sizeof (char));
1879                        snprintf (path_script, path_length, "%s%s%s%s%s",
1880                                  weechat_home, DIR_SEPARATOR, "ruby",
1881                                  DIR_SEPARATOR, argv[1]);
1882                    }
1883                    plugin_load (PLUGIN_TYPE_RUBY,
1884                                 (path_script) ? path_script : argv[1]);
1885                    if (path_script)
1886                        free (path_script);
1887                }
1888                else
1889                {
1890                    irc_display_prefix (NULL, PREFIX_ERROR);
1891                    gui_printf (NULL,
1892                                _("%s unknown option for \"%s\" command\n"),
1893                                WEECHAT_ERROR, "ruby");
1894                }
1895                break;
1896            default:
1897                irc_display_prefix (NULL, PREFIX_ERROR);
1898                gui_printf (NULL,
1899                            _("%s wrong argument count for \"%s\" command\n"),
1900                            WEECHAT_ERROR, "ruby");
1901        }
1902    #else
1903        irc_display_prefix (NULL, PREFIX_ERROR);
1904        gui_printf (NULL,
1905                    _("WeeChat was build without Ruby support.\n"
1906                    "Please rebuild WeeChat with "
1907                    "\"--enable-ruby\" option for ./configure script\n"));
1908        /* make gcc happy */
1909        (void) argc;
1910        (void) argv;
1911    #endif /* PLUGIN_RUBY */
1912            
1913      return 0;      return 0;
1914  }  }

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65

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