1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 14:56:39 +02:00

Allow script commands to reload only one script

This commit is contained in:
Sebastien Helleu
2010-02-23 10:51:59 +01:00
parent 27bf347e1c
commit 3d3dc1593d
31 changed files with 257 additions and 134 deletions
+37
View File
@@ -353,6 +353,38 @@ weechat_lua_unload_name (const char *name)
}
}
/*
* weechat_lua_reload_name: reload a Lua script by name
*/
void
weechat_lua_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_lua_plugin, lua_scripts, name);
if (ptr_script)
{
filename = strdup (ptr_script->filename);
if (filename)
{
weechat_lua_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
LUA_PLUGIN_NAME, name);
weechat_lua_load (filename);
free (filename);
}
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), LUA_PLUGIN_NAME, name);
}
}
/*
* weechat_lua_unload_all: unload all Lua scripts
*/
@@ -432,6 +464,11 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Lua script */
weechat_lua_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Lua script */
+37
View File
@@ -506,6 +506,38 @@ weechat_perl_unload_all ()
}
}
/*
* weechat_perl_reload_name: reload a Perl script by name
*/
void
weechat_perl_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
if (ptr_script)
{
filename = strdup (ptr_script->filename);
if (filename)
{
weechat_perl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PERL_PLUGIN_NAME, name);
weechat_perl_load (filename);
free (filename);
}
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), PERL_PLUGIN_NAME, name);
}
}
/*
* weechat_perl_command_cb: callback for "/perl" command
*/
@@ -572,6 +604,11 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Perl script */
weechat_perl_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Perl script */
@@ -602,6 +602,38 @@ weechat_python_unload_all ()
}
}
/*
* weechat_python_reload_name: reload a Python script by name
*/
void
weechat_python_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_python_plugin, python_scripts, name);
if (ptr_script)
{
filename = strdup (ptr_script->filename);
if (filename)
{
weechat_python_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
PYTHON_PLUGIN_NAME, name);
weechat_python_load (filename);
free (filename);
}
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, name);
}
}
/*
* weechat_python_cmd: callback for "/python" command
*/
@@ -668,6 +700,11 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Python script */
weechat_python_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Python script */
+37
View File
@@ -642,6 +642,38 @@ weechat_ruby_unload_name (const char *name)
}
}
/*
* weechat_ruby_reload_name: reload a Ruby script by name
*/
void
weechat_ruby_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name);
if (ptr_script)
{
filename = strdup (ptr_script->filename);
if (filename)
{
weechat_ruby_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
RUBY_PLUGIN_NAME, name);
weechat_ruby_load (filename);
free (filename);
}
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), RUBY_PLUGIN_NAME, name);
}
}
/*
* weechat_ruby_unload_all: unload all Ruby scripts
*/
@@ -721,6 +753,11 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Ruby script */
weechat_ruby_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Ruby script */
+2 -2
View File
@@ -248,7 +248,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
" || listfull %s"
" || load %(filename)"
" || autoload"
" || reload"
" || reload %s"
" || unload %s",
"%s",
string);
@@ -257,7 +257,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
N_("list/load/unload scripts"),
N_("[list [name]] | [listfull [name]] | "
"[load filename] | [autoload] | "
"[reload] | [unload [name]]"),
"[reload [name]] | [unload [name]]"),
N_("filename: script (file) to load\n"
"name: a script name\n\n"
"Without argument, this command "
+37
View File
@@ -301,6 +301,38 @@ weechat_tcl_unload_all ()
}
}
/*
* weechat_tcl_reload_name: reload a Tcl script by name
*/
void
weechat_tcl_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
if (ptr_script)
{
filename = strdup (ptr_script->filename);
if (filename)
{
weechat_tcl_unload (ptr_script);
weechat_printf (NULL,
weechat_gettext ("%s: script \"%s\" unloaded"),
TCL_PLUGIN_NAME, name);
weechat_tcl_load (filename);
free (filename);
}
}
else
{
weechat_printf (NULL,
weechat_gettext ("%s%s: script \"%s\" not loaded"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, name);
}
}
/*
* weechat_tcl_command_cb: callback for "/tcl" command
*/
@@ -367,6 +399,11 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
else if (weechat_strcasecmp (argv[1], "reload") == 0)
{
/* reload one Tcl script */
weechat_tcl_reload_name (argv_eol[2]);
}
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Tcl script */