1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

script: add option script.look.quiet_actions (no messages when installing/removing/loading/unloading scripts on script buffer)

This commit is contained in:
Sebastien Helleu
2012-08-21 18:57:49 +02:00
parent cc5118b3b6
commit 129f32ce8e
69 changed files with 1113 additions and 705 deletions
+63 -34
View File
@@ -37,7 +37,7 @@
char *script_actions = NULL;
void script_action_install ();
void script_action_install (int quiet);
/*
@@ -118,8 +118,9 @@ script_action_load (const char *name, int quiet)
/* execute command (for example: "/perl load iset.pl") */
snprintf (str_command, sizeof (str_command),
"/%s load %s",
"/%s load %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
}
@@ -183,8 +184,9 @@ script_action_unload (const char *name, int quiet)
if (ptr_registered_name)
{
snprintf (str_command, sizeof (str_command),
"/%s unload %s",
"/%s unload %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_registered_name);
weechat_command (NULL, str_command);
}
@@ -209,8 +211,9 @@ script_action_unload (const char *name, int quiet)
if (strcmp (ptr_registered_name, name) == 0)
{
snprintf (str_command, sizeof (str_command),
"/%s unload %s",
"/%s unload %s%s",
script_language[i],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
return;
@@ -287,8 +290,9 @@ script_action_reload (const char *name, int quiet)
if (ptr_registered_name)
{
snprintf (str_command, sizeof (str_command),
"/%s reload %s",
"/%s reload %s%s",
script_language[language],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_registered_name);
weechat_command (NULL, str_command);
}
@@ -313,8 +317,9 @@ script_action_reload (const char *name, int quiet)
if (strcmp (ptr_registered_name, name) == 0)
{
snprintf (str_command, sizeof (str_command),
"/%s reload %s",
"/%s reload %s%s",
script_language[i],
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
name);
weechat_command (NULL, str_command);
return;
@@ -340,10 +345,9 @@ int
script_action_installnext_timer_cb (void *data, int remaining_calls)
{
/* make C compiler happy */
(void) data;
(void) remaining_calls;
script_action_install ();
script_action_install ((data) ? 1 : 0);
return WEECHAT_RC_OK;
}
@@ -357,11 +361,11 @@ script_action_install_process_cb (void *data, const char *command,
int return_code, const char *out,
const char *err)
{
char *pos, *filename, str_signal[256];
char *pos, *filename, *filename2, str_signal[256];
int quiet, length;
struct t_repo_script *ptr_script;
/* make C compiler happy */
(void) data;
quiet = (data) ? 1 : 0;
if (return_code >= 0)
{
@@ -386,18 +390,29 @@ script_action_install_process_cb (void *data, const char *command,
filename = script_config_get_script_download_filename (ptr_script);
if (filename)
{
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename);
length = 3 + strlen (filename) + 1;
filename2 = malloc (length);
if (filename2)
{
snprintf (filename2, length,
"%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
filename);
snprintf (str_signal, sizeof (str_signal),
"%s_script_install",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename2);
free (filename2);
}
free (filename);
}
/* schedule install of next script */
weechat_hook_timer (10, 0, 1,
&script_action_installnext_timer_cb, NULL);
&script_action_installnext_timer_cb,
(quiet) ? (void *)1 : (void *)0);
}
}
}
@@ -410,7 +425,7 @@ script_action_install_process_cb (void *data, const char *command,
*/
void
script_action_install ()
script_action_install (int quiet)
{
struct t_repo_script *ptr_script, *ptr_script_to_install;
char *filename, *url;
@@ -446,17 +461,20 @@ script_action_install ()
url = malloc (length);
if (url)
{
weechat_printf (NULL,
_("%s: downloading script \"%s\"..."),
SCRIPT_PLUGIN_NAME,
ptr_script_to_install->name_with_extension);
if (!weechat_config_boolean (script_config_look_quiet_actions))
{
weechat_printf (NULL,
_("%s: downloading script \"%s\"..."),
SCRIPT_PLUGIN_NAME,
ptr_script_to_install->name_with_extension);
}
snprintf (url, length, "url:%s",
ptr_script_to_install->url);
weechat_hashtable_set (options, "file_out", filename);
weechat_hook_process_hashtable (url, options, 30000,
&script_action_install_process_cb,
NULL);
(quiet) ? (void *)1 : (void *)0);
free (url);
}
weechat_hashtable_free (options);
@@ -474,7 +492,8 @@ void
script_action_remove (const char *name, int quiet)
{
struct t_repo_script *ptr_script;
char str_signal[256];
char str_signal[256], *filename;
int length;
ptr_script = script_repo_search_by_name_ext (name);
if (ptr_script)
@@ -499,12 +518,22 @@ script_action_remove (const char *name, int quiet)
}
else
{
snprintf (str_signal, sizeof (str_signal),
"%s_script_remove",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
ptr_script->name_with_extension);
length = 3 + strlen (ptr_script->name_with_extension) + 1;
filename = malloc (length);
if (filename)
{
snprintf (filename, length,
"%s%s",
(quiet && weechat_config_boolean (script_config_look_quiet_actions)) ? "-q " : "",
ptr_script->name_with_extension);
snprintf (str_signal, sizeof (str_signal),
"%s_script_remove",
script_language[ptr_script->language]);
weechat_hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING,
filename);
free (filename);
}
}
}
else
@@ -717,7 +746,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
}
else if (weechat_strcasecmp (argv[0], "remove") == 0)
{
@@ -758,7 +787,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
}
else if (weechat_strcasecmp (argv[0], "hold") == 0)
{
@@ -798,7 +827,7 @@ script_action_run ()
}
}
if (script_found)
script_action_install ();
script_action_install (quiet);
else
{
weechat_printf (NULL,
+37 -16
View File
@@ -46,10 +46,21 @@ script_command_action (struct t_gui_buffer *buffer, const char *action,
char str_action[4096];
long value;
char *error;
int quiet;
if (arguments)
{
/* action with arguments on command line */
quiet = 0;
if (strncmp (arguments, "-q ", 3) == 0)
{
quiet = 1;
arguments += 3;
while (arguments[0] == ' ')
{
arguments++;
}
}
error = NULL;
value = strtol (arguments, &error, 10);
if (error && !error[0])
@@ -58,15 +69,21 @@ script_command_action (struct t_gui_buffer *buffer, const char *action,
if (ptr_script)
{
snprintf (str_action, sizeof (str_action),
"%s %s", action, ptr_script->name_with_extension);
script_action_schedule (str_action, need_repository, 0);
"%s%s %s",
(quiet) ? "-q " : "",
action,
ptr_script->name_with_extension);
script_action_schedule (str_action, need_repository, quiet);
}
}
else
{
snprintf (str_action, sizeof (str_action),
"%s %s", action, arguments);
script_action_schedule (str_action, need_repository, 0);
"%s%s %s",
(quiet) ? "-q " : "",
action,
arguments);
script_action_schedule (str_action, need_repository, quiet);
}
}
else if (script_buffer && (buffer == script_buffer))
@@ -260,23 +277,26 @@ script_command_init ()
N_("WeeChat scripts manager"),
N_("list || search <text> || show <script>"
" || load|unload|reload <script> [<script>...]"
" || install|remove|hold <script> [<script>...]"
" || install|remove|installremove|hold [-q] <script> [<script>...]"
" || upgrade || update"),
N_(" list: list loaded scripts (all languages)\n"
" search: search scripts by tags or text and "
N_(" list: list loaded scripts (all languages)\n"
" search: search scripts by tags or text and "
"display result on scripts buffer\n"
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
" reload: reload script(s)\n"
" install: install/upgrade script(s)\n"
" remove: remove script(s)\n"
" hold: hold/unhold script(s) (a script held "
" show: show detailed info about a script\n"
" load: load script(s)\n"
" unload: unload script(s)\n"
" reload: reload script(s)\n"
" install: install/upgrade script(s)\n"
" remove: remove script(s)\n"
"installremove: install or remove script(s), "
"depending on current state\n"
" hold: hold/unhold script(s) (a script held "
"will not be upgraded any more and cannot be "
"removed)\n"
" upgrade: upgrade all installed scripts which "
" -q: quiet mode: do not display messages\n"
" upgrade: upgrade all installed scripts which "
"are obsolete (new version available)\n"
" update: update local scripts cache\n\n"
" update: update local scripts cache\n\n"
"Without argument, this command opens a buffer "
"with list of scripts.\n\n"
"On script buffer, the possible status for each "
@@ -329,6 +349,7 @@ script_command_init ()
"%(guile_script)|%*"
" || install %(script_scripts)|%*"
" || remove %(script_scripts_installed)|%*"
" || installremove %(script_scripts)|%*"
" || hold %(script_scripts)|%*"
" || update"
" || upgrade",
+9
View File
@@ -40,6 +40,7 @@ struct t_config_section *script_config_section_scripts = NULL;
/* script config, look section */
struct t_config_option *script_config_look_columns;
struct t_config_option *script_config_look_quiet_actions;
struct t_config_option *script_config_look_sort;
struct t_config_option *script_config_look_translate_description;
struct t_config_option *script_config_look_use_keys;
@@ -358,6 +359,14 @@ script_config_init ()
"%W=max_weechat)"),
NULL, 0, 0, "%s %n %V %v %u | %d | %t", NULL, 0,
NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
script_config_look_quiet_actions = weechat_config_new_option (
script_config_file, ptr_section,
"quiet_actions", "boolean",
N_("quiet actions on script buffer: do not display messages on core "
"buffer when scripts are installed/removed/loaded/unloaded (only "
"errors are displayed)"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL);
script_config_look_sort = weechat_config_new_option (
script_config_file, ptr_section,
"sort", "string",
+1
View File
@@ -25,6 +25,7 @@
struct t_repo_script;
extern struct t_config_option *script_config_look_columns;
extern struct t_config_option *script_config_look_quiet_actions;
extern struct t_config_option *script_config_look_sort;
extern struct t_config_option *script_config_look_translate_description;
extern struct t_config_option *script_config_look_use_keys;