From d226946f59ec1174a58867105a392c687e6b3334 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 21:26:53 +0200 Subject: [PATCH] fix(cli): aliases to pseudo commands To understand what's going on here, understand this: this is a regular CLI command: (defcli! (doom sync) () ...) And this is a pseudo command: (defcli! (:before doom sync) () ...) If a pseudo command is aliased to another pseudo command: (defcli! (:before doom (foo bar baz)) ...) In which case, ':before doom bar' and ':before doom baz' are aliases for ':before doom foo', there was a bug that cut out the keyword, so in actuality, ':before doom {bar,baz}' were aliased to 'doom bar'. This fixes that, and the peculiar issue of 'doom purge' executing 'doom build' due to this, living in core/cli/packages.el: (defcli! (:before (build b purge p)) (&context context) (require 'comp nil t) (doom-initialize-core-packages)) Ref: https://github.com/doomemacs/doomemacs/issues/4273#issuecomment-1159610824 --- core/core-cli-lib.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/core-cli-lib.el b/core/core-cli-lib.el index eaa71f475..65f31ef4b 100644 --- a/core/core-cli-lib.el +++ b/core/core-cli-lib.el @@ -270,18 +270,18 @@ COMMAND can be a command path (list of strings), a `doom-cli' struct, or a Returned in the order they will execute. Includes pseudo CLIs." (let* ((command (doom-cli--command command)) - (pseudo? (keywordp (car-safe command))) - (paths (doom-cli--command-expand command t)) - results) - (unless pseudo? - (dolist (path paths) - (push (cons :before path) results))) + (paths (nreverse (doom-cli--command-expand command t))) + results clis) + (push '(:after) results) + (dolist (path paths) + (push (cons :after path) results)) (push command results) - (unless pseudo? - (dolist (path (reverse paths)) - (push (cons :after path) results))) - (setq results (delq nil (mapcar #'doom-cli-get results)) - results (nreverse (delete-dups results))))) + (dolist (path (nreverse paths)) + (push (cons :before path) results)) + (push '(:before) results) + (dolist (result (nreverse results) clis) + (when-let (cli (doom-cli-get result)) + (cl-pushnew cli clis :test #'equal :key #'doom-cli-key))))) (defun doom-cli-prop (cli prop &optional null-value) "Returns a PROPerty of CLI's plist, or NULL-VALUE if it doesn't exist." @@ -1485,7 +1485,7 @@ ignored. :command alias :type type :docs docs - :alias target + :alias (delq nil (cons type target)) :plist (append plist '(:hide t))) doom-cli--table)) (dolist (partial commands)