diff options
Diffstat (limited to 'src/plugins/scripts/ruby')
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 166b4685a..8179d758d 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -643,6 +643,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 */ |