From 7f28dcd1efbfd7191ed43856119b90ee47a2f65d Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Wed, 16 Jun 2021 20:24:41 +0200 Subject: degesch: make "/help /command" work Works for aliases as well. Resolves a TODO entry. --- NEWS | 2 ++ degesch.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 2a8a9a1..614c600 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ * degesch: /set +=/-= now treats its argument as a string array + * degesch: made "/help /command" work the same way as "/help command" does + * censor.lua: now stripping colours from censored messages; their attributes are also configurable rather than always black on black diff --git a/degesch.c b/degesch.c index f9c0309..ed5b1ce 100644 --- a/degesch.c +++ b/degesch.c @@ -12188,8 +12188,9 @@ handle_command_help (struct handler_args *a) if (!*a->arguments) return show_command_list (ctx); - // TODO: we should probably also accept commands names with a leading slash - char *command = cut_word (&a->arguments); + const char *word = cut_word (&a->arguments); + + const char *command = word + (*word == '/'); for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++) { struct command_handler *handler = &g_command_handlers[i]; @@ -12197,13 +12198,13 @@ handle_command_help (struct handler_args *a) return show_command_help (ctx, handler); } - if (try_handle_command_help_option (ctx, command)) + if (try_handle_command_help_option (ctx, word)) return true; if (str_map_find (get_aliases_config (ctx), command)) log_global_status (ctx, "/#s is an alias", command); else - log_global_error (ctx, "#s: #s", "No such command or option", command); + log_global_error (ctx, "#s: #s", "No such command or option", word); return true; } -- cgit v1.2.3-70-g09d2