From 13e73d52d37ce2c80e2d44e45b10737f90e24df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 13 Oct 2023 23:54:19 +0200 Subject: [PATCH] core: allow wildcard in command `/proxy del` (issue #1956) --- src/core/wee-command.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 0a382cdf5..6becca420 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -5447,10 +5447,10 @@ command_proxy_list () COMMAND_CALLBACK(proxy) { - int type; + struct t_proxy *ptr_proxy, *ptr_next_proxy; + char *error, *name; + int type, i; long value; - char *error; - struct t_proxy *ptr_proxy; /* make C compiler happy */ (void) pointer; @@ -5512,24 +5512,22 @@ COMMAND_CALLBACK(proxy) if (string_strcmp (argv[1], "del") == 0) { COMMAND_MIN_ARGS(3, "del"); - if (string_strcmp (argv[2], "-all") == 0) + for (i = 2; i < argc; i++) { - proxy_free_all (); - gui_chat_printf (NULL, _("All proxies have been deleted")); - } - else - { - ptr_proxy = proxy_search (argv[2]); - if (!ptr_proxy) + ptr_proxy = weechat_proxies; + while (ptr_proxy) { - gui_chat_printf (NULL, - _("%sProxy \"%s\" not found"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[2]); - return WEECHAT_RC_OK; + ptr_next_proxy = ptr_proxy->next_proxy; + if (string_match (ptr_proxy->name, argv[i], 1)) + { + name = strdup (ptr_proxy->name); + proxy_free (ptr_proxy); + gui_chat_printf (NULL, _("Proxy \"%s\" deleted"), name); + if (name) + free (name); + } + ptr_proxy = ptr_next_proxy; } - proxy_free (ptr_proxy); - gui_chat_printf (NULL, _("Proxy deleted")); } return WEECHAT_RC_OK; } @@ -8999,7 +8997,7 @@ command_init () /* TRANSLATORS: only text between angle brackets (eg: "") must be translated */ N_("list" " || add
[ []]" - " || del |-all" + " || del | [|...]" " || set