degesch: make "/help /command" work

Works for aliases as well.  Resolves a TODO entry.
This commit is contained in:
Přemysl Eric Janouch 2021-06-16 20:24:41 +02:00
parent 61c52d793c
commit 7f28dcd1ef
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 7 additions and 4 deletions

2
NEWS
View File

@ -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

View File

@ -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;
}