aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-06-16 20:24:41 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-06-16 21:57:47 +0200
commit7f28dcd1efbfd7191ed43856119b90ee47a2f65d (patch)
tree04df913b4582710ae35a3f3bbbdf8abc856feb23
parent61c52d793c1ea2f9bdc46add2709a285ed561afa (diff)
downloadxK-7f28dcd1efbfd7191ed43856119b90ee47a2f65d.tar.gz
xK-7f28dcd1efbfd7191ed43856119b90ee47a2f65d.tar.xz
xK-7f28dcd1efbfd7191ed43856119b90ee47a2f65d.zip
degesch: make "/help /command" work
Works for aliases as well. Resolves a TODO entry.
-rw-r--r--NEWS2
-rw-r--r--degesch.c9
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;
}