diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-14 07:58:21 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-14 07:58:21 +0200 |
commit | a02743b229ac5b9d7710590e1e3f57caf710652a (patch) | |
tree | faea4b6ec506696eb548a6cdf0635faafa9d35ee /src/core | |
parent | 3fb322be8f278f63b88b0c212d17d9f1d08d609a (diff) | |
download | weechat-a02743b229ac5b9d7710590e1e3f57caf710652a.zip |
core: add option weechat.look.confirm_upgrade (closes #463)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 46 | ||||
-rw-r--r-- | src/core/wee-config.c | 7 | ||||
-rw-r--r-- | src/core/wee-config.h | 1 |
3 files changed, 44 insertions, 10 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index aece0e78a..e37ebc35c 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -4861,9 +4861,10 @@ COMMAND_CALLBACK(quit) if (CONFIG_BOOLEAN(config_look_confirm_quit) && !confirm_ok) { gui_chat_printf (NULL, - _("%sYou must confirm quit command with extra " - "argument \"-yes\" (see /help quit)"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + _("%sYou must confirm /%s command with extra " + "argument \"-yes\" (see /help %s)"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + "quit", "quit"); return WEECHAT_RC_OK; } @@ -6013,14 +6014,37 @@ COMMAND_CALLBACK(upgrade) char *ptr_binary; char *exec_args[7] = { NULL, "-a", "--dir", NULL, "--upgrade", NULL }; struct stat stat_buf; - int rc, quit; + int confirm_ok, index_args, rc, quit; /* make C compiler happy */ (void) data; (void) buffer; - if ((argc > 1) && (string_strcasecmp (argv[1], "-dummy") == 0)) + confirm_ok = 0; + index_args = 1; + + if ((argc > 1) && (string_strcasecmp (argv[1], "-yes") == 0)) + { + confirm_ok = 1; + index_args = 2; + } + + /* if confirmation is required, check that "-yes" is given */ + if (CONFIG_BOOLEAN(config_look_confirm_upgrade) && !confirm_ok) + { + gui_chat_printf (NULL, + _("%sYou must confirm /%s command with extra " + "argument \"-yes\" (see /help %s)"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + "upgrade", "upgrade"); + return WEECHAT_RC_OK; + } + + if ((argc > index_args) + && (string_strcasecmp (argv[index_args], "-dummy") == 0)) + { return WEECHAT_RC_OK; + } /* * it is forbidden to upgrade while there are some background process @@ -6038,13 +6062,13 @@ COMMAND_CALLBACK(upgrade) ptr_binary = NULL; quit = 0; - if (argc > 1) + if (argc > index_args) { - if (string_strcasecmp (argv[1], "-quit") == 0) + if (string_strcasecmp (argv[index_args], "-quit") == 0) quit = 1; else { - ptr_binary = string_expand_home (argv_eol[1]); + ptr_binary = string_expand_home (argv_eol[index_args]); if (ptr_binary) { /* check if weechat binary is here and executable by user */ @@ -7853,8 +7877,10 @@ command_init () hook_command ( NULL, "upgrade", N_("upgrade WeeChat without disconnecting from servers"), - N_("[<path_to_binary>|-quit]"), - N_("path_to_binary: path to WeeChat binary (default is current binary)\n" + N_("[-yes] [<path_to_binary>|-quit]"), + N_(" -yes: required if option weechat.look.confirm_upgrade " + "is enabled\n" + "path_to_binary: path to WeeChat binary (default is current binary)\n" " -dummy: do nothing (option used to prevent accidental " "completion with \"-quit\")\n" " -quit: close *ALL* connections, save session and quit " diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 350b43656..36b781de4 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -107,6 +107,7 @@ struct t_config_option *config_look_color_real_white; struct t_config_option *config_look_command_chars; struct t_config_option *config_look_command_incomplete; struct t_config_option *config_look_confirm_quit; +struct t_config_option *config_look_confirm_upgrade; struct t_config_option *config_look_day_change; struct t_config_option *config_look_day_change_message_1date; struct t_config_option *config_look_day_change_message_2dates; @@ -2380,6 +2381,12 @@ config_weechat_init_options () N_("if set, /quit command must be confirmed with extra argument " "\"-yes\" (see /help quit)"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + config_look_confirm_upgrade = config_file_new_option ( + weechat_config_file, ptr_section, + "confirm_upgrade", "boolean", + N_("if set, /upgrade command must be confirmed with extra argument " + "\"-yes\" (see /help upgrade)"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_day_change = config_file_new_option ( weechat_config_file, ptr_section, "day_change", "boolean", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index d851f3476..7a8651281 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -154,6 +154,7 @@ extern struct t_config_option *config_look_color_real_white; extern struct t_config_option *config_look_command_chars; extern struct t_config_option *config_look_command_incomplete; extern struct t_config_option *config_look_confirm_quit; +extern struct t_config_option *config_look_confirm_upgrade; extern struct t_config_option *config_look_day_change; extern struct t_config_option *config_look_day_change_message_1date; extern struct t_config_option *config_look_day_change_message_2dates; |