From ab7f7058f3ce64985b935d7c50b1bb8a8e1b96fc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 22:16:38 +0200 Subject: [PATCH] docs(cli): show correct command in error message Before: $ doom ci hook commit-msg test Error: "doom ci" expected 0 arguments, but got 1 Usage: doom ci COMMAND [ARGS...] See 'doom h[elp] ci' or 'doom ci {-?,--help}' for documentation. After: $ doom ci hook commit-msg test Error: ":before doom ci" expected 0 arguments, but got 1 Usage: doom ci hook commit-msg FILE See 'doom h[elp] ci hook commit-msg' or 'doom ci hook commit-msg {-?,--help}' for documentation. --- core/core-cli-lib.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/core-cli-lib.el b/core/core-cli-lib.el index 132a86e82..05e84b1e6 100644 --- a/core/core-cli-lib.el +++ b/core/core-cli-lib.el @@ -375,7 +375,7 @@ Return nil if CLI (a `doom-cli') has no explicit documentation." (when (or (< argc min) (> argc max)) (signal 'doom-cli-wrong-number-of-arguments-error - (list (doom-cli--command context) nil args min max))) + (list (doom-cli-key cli) nil args min max))) (dolist (sym spec) (setf (alist-get sym alist) (if args (pop args)))) (dolist (type `((&args . ,args) @@ -1667,14 +1667,17 @@ errors to `doom-cli-error-file')." (doom-cli-wrong-number-of-arguments-error (pcase-let ((`(,command ,flag ,args ,min ,max) (cdr e))) (print! (red "Error: %S expected %s argument%s, but got %d") - (or flag (doom-cli-command-string (cdr command))) + (or flag (doom-cli-command-string + (if (keywordp (car command)) + command + (cdr command)))) (if (or (= min max) (= max most-positive-fixnum)) min (format "%d-%d" min max)) (if (or (= min 0) (> min 1)) "s" "") (length args)) - (doom-cli-call `(:help "--synopsis" "--postamble" ,@(cdr command)) context e)) + (doom-cli-call `(:help "--synopsis" "--postamble" ,@(cdr (doom-cli--command context))) context e)) 5) (doom-cli-unrecognized-option-error (print! (red "Error: unknown option %s") (cadr e))