Refactor interactive CLI commands

Also fixes an issue where output wasn't colored correctly.
This commit is contained in:
Henrik Lissner 2019-04-26 22:11:37 -04:00
parent 8e453462c7
commit 26050bb1d7
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -2,11 +2,11 @@
(require 'core-cli) (require 'core-cli)
(defun doom--run (command &optional yes) ;;;###autoload
(defun doom-cli-run (command &rest _args)
(let* ((default-directory doom-emacs-dir) (let* ((default-directory doom-emacs-dir)
(doom-auto-accept yes)
(buf (get-buffer-create " *bin/doom*")) (buf (get-buffer-create " *bin/doom*"))
(wconf (current-window-configuration)) (doom-message-backend 'ansi)
(ignore-window-parameters t) (ignore-window-parameters t)
(noninteractive t) (noninteractive t)
(standard-output (standard-output
@ -33,19 +33,22 @@
(defun doom//autoloads (&optional yes) (defun doom//autoloads (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "autoloads" yes)) (let ((doom-auto-accept yes))
(doom-cli-run "autoloads")))
;;;###autoload ;;;###autoload
(defun doom//update (&optional yes) (defun doom//update (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "update" yes)) (let ((doom-auto-accept yes))
(doom-cli-run "update")))
;;;###autoload ;;;###autoload
(defun doom//upgrade (&optional yes) (defun doom//upgrade (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "upgrade" yes) (let ((doom-auto-accept yes))
(doom-cli-run "upgrade"))
(when (y-or-n-p "You must restart Emacs for the upgrade to take effect. Restart?") (when (y-or-n-p "You must restart Emacs for the upgrade to take effect. Restart?")
(doom/restart-and-restore))) (doom/restart-and-restore)))
@ -53,16 +56,19 @@
(defun doom//install (&optional yes) (defun doom//install (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "install" yes)) (let ((doom-auto-accept yes))
(doom-cli-run "install")))
;;;###autoload ;;;###autoload
(defun doom//autoremove (&optional yes) (defun doom//autoremove (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "autoremove" yes)) (let ((doom-auto-accept yes))
(doom-cli-run "autoremove")))
;;;###autoload ;;;###autoload
(defun doom//refresh (&optional yes) (defun doom//refresh (&optional yes)
"TODO" "TODO"
(interactive "P") (interactive "P")
(doom--run "refresh" yes)) (let ((doom-auto-accept yes))
(doom-cli-run "refresh")))