fix(cli): autoloaded clis aliased to wrong commands

I use a shortcut like this to autoload multiple (different) CLIs living
in the same file:

  (defautoload! ((foo bar baz)) "file")

However, this creates premature aliases between autoloaded CLIs. When
'baz' is invoked, instead of loading "file", it resolves to 'foo'
first *then* loads it, causing 'foo' to be executed instead of 'baz'.
This commit fixes that.

Also, minor refactor: I removed the plist argument from a
doom-cli-command-normalize call because it wasn't needed or useful to
the consumer of its return value.

Amend: d226946f59
This commit is contained in:
Henrik Lissner 2022-06-22 01:54:55 +02:00
parent 93fc74a143
commit 834ff3ea85
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -1511,7 +1511,8 @@ ignored.
:command alias
:type type
:docs docs
:alias (delq nil (cons type target))
:autoload autoload
:alias (unless autoload (delq nil (cons type target)))
:plist (append plist '(:hide t)))
doom-cli--table))
(dolist (partial commands)
@ -1550,7 +1551,7 @@ WHEN specifies what version this command was rendered obsolete."
(defmacro defautoload! (commandspec &optional path &rest plist)
"Defer loading of PATHS until PREFIX is called."
`(let* ((doom-cli--plist (append (list ,@plist) doom-cli--plist))
(commandspec (doom-cli-command-normalize ',commandspec doom-cli--plist))
(commandspec (doom-cli-command-normalize ',commandspec))
(commands (doom-cli--command-expand commandspec))
(path (or ,path
(when-let* ((cmd (car commands))