From 6eefd4c1df14b65f2b1007d833d12710e7b31010 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 13:01:59 +0200 Subject: [PATCH] fix(cli): wrong-type-arg error on unrecognized command If you type an unrecognized command, you get an "Error: unrecognized command X" error, then a list of similar commands, followed by a recommendation to check out 'doom help Y' or 'doom --help Y', where Y is the nearest recognized parent command. E.g. 'doom ci blah' is an unknown command, but 'doom ci' is known, therefore Y = 'doom ci'. This fix ensures that Y is properly resolved. Amend: 6c0b7e1530a6 --- core/cli/help.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cli/help.el b/core/cli/help.el index 1af2a787c..e91d56481 100644 --- a/core/cli/help.el +++ b/core/cli/help.el @@ -49,7 +49,7 @@ OPTIONS: (cli (doom-cli-get command t)) (rcli (doom-cli-get cli)) (fallbackcli (cl-loop with targets = (doom-cli--command-expand (butlast command) t) - for cmd in (cons command (nreverse targets)) + for cmd in (cons command targets) if (doom-cli-get cmd t) return it))) (cond (commands? @@ -112,7 +112,7 @@ OPTIONS: (print! "See %s for documentation." (join (cl-loop with spec = `((?p . ,(doom-cli-context-prefix context)) - (?c . ,(doom-cli-command-string (cdr (doom-cli-command cli))))) + (?c . ,(doom-cli-command-string (cdr (doom-cli-command (or cli fallbackcli)))))) for cmd in doom-help-commands for formatted = (trim (format-spec cmd spec)) collect (replace-regexp-in-string