refactor(cli): return unresolved CLIs from doom-cli-find

'doom help' is aliased to the pseudo command ':help'. (doom-cli-find
'("doom" "help")) would return a list of all CLIs that are pertinent to
'doom help's execution, but it resolves aliases, making it unclear to
recipients of this list what the initial command was.

This requires callers resolve the CLIs themselves, but at least now the
user has the choice.
This commit is contained in:
Henrik Lissner 2022-06-21 14:44:26 +02:00
parent 23ee89ec08
commit 9f2d6262e5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -281,8 +281,10 @@ Returned in the order they will execute. Includes pseudo CLIs."
(push (cons :before path) results)) (push (cons :before path) results))
(push '(:before) results) (push '(:before) results)
(dolist (result (nreverse results) clis) (dolist (result (nreverse results) clis)
(when-let (cli (doom-cli-get result)) (when-let (cli (doom-cli-get result t))
(cl-pushnew cli clis :test #'equal :key #'doom-cli-key))))) (cl-pushnew cli clis
:test #'equal
:key #'doom-cli-key)))))
(defun doom-cli-prop (cli prop &optional null-value) (defun doom-cli-prop (cli prop &optional null-value)
"Returns a PROPerty of CLI's plist, or NULL-VALUE if it doesn't exist." "Returns a PROPerty of CLI's plist, or NULL-VALUE if it doesn't exist."
@ -637,7 +639,9 @@ executable context."
((let ((seen '(t)) ((let ((seen '(t))
runners) runners)
(dolist (cli (doom-cli-find command (doom-cli-type cli))) (dolist (cli (doom-cli-find command (doom-cli-type cli)))
(push (cons cli (doom-cli--bindings cli context seen)) runners)) (push (cons (doom-cli-get cli)
(doom-cli--bindings cli context seen))
runners))
(pcase-dolist (`(,cli . ,bindings) (nreverse runners)) (pcase-dolist (`(,cli . ,bindings) (nreverse runners))
(doom-cli-execute cli bindings)) (doom-cli-execute cli bindings))
context))))) context)))))