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: 6c0b7e1530
This commit is contained in:
Henrik Lissner 2022-06-19 13:01:59 +02:00
parent 446e1432bc
commit 6eefd4c1df
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

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