feat(cli): defcli-obsolete!: allow arbitrary obsolescence message

Ala `make-obsolete`.
This commit is contained in:
Henrik Lissner
2024-12-08 19:18:12 -05:00
parent 254a8d38a7
commit 7de9723334

View File

@ -1750,20 +1750,27 @@ TARGET is not a command specification, and should be a command list."
See `defcli!' for information about COMMANDSPEC. See `defcli!' for information about COMMANDSPEC.
TARGET is simply a command list. TARGET is simply a command list.
WHEN specifies what version this command was rendered obsolete." WHEN specifies what version this command was rendered obsolete."
`(let ((ncommand (doom-cli-command-normalize (backquote ,target) doom-cli--group-plist))) `(let* ((target (backquote ,target)))
(defcli! ,commandspec (&context _context &cli cli &rest args) (defcli! ,commandspec (&context _context &cli cli &rest args)
:docs (format "An obsolete alias for '%s'." (doom-cli-command-string ncommand)) :docs (if (stringp target)
:obsolete (cons ncommand ,when) (format "An obsolete command: %s" target)
(format "An obsolete alias for '%s'."
(doom-cli-command-string
(doom-cli-command-normalize target doom-cli--group-plist))))
:obsolete (cons target ,when)
:hide t :hide t
(let* ((obsolete (plist-get (doom-cli-plist cli) :obsolete)) (cl-destructuring-bind (target . when)
(newcmd (car obsolete)) (plist-get (doom-cli-plist cli) :obsolete)
(when (cdr obsolete))) (print! (warn "'%s' was %s in %s")
(print! (warn "'%s' was deprecated in %s")
(doom-cli-command-string cli) (doom-cli-command-string cli)
(if (stringp target) "removed" "deprecated")
when) when)
(if (stringp target)
(print! (warn "%s." target))
(setq target (doom-cli-command-normalize target doom-cli--group-plist))
(print! (warn "It will eventually be removed; use '%s' instead.") (print! (warn "It will eventually be removed; use '%s' instead.")
(doom-cli-command-string newcmd)) (doom-cli-command-string target))
(call! ',target args))))) (call! ',target args))))))
(defmacro defcli-stub! (commandspec &optional _argspec &rest body) (defmacro defcli-stub! (commandspec &optional _argspec &rest body)
"Define a stub CLI, which will throw an error if invoked. "Define a stub CLI, which will throw an error if invoked.