core-cli: minor refactors
This commit is contained in:
parent
518c97a2ac
commit
a6dc9bf7e5
2 changed files with 25 additions and 27 deletions
20
bin/doom
20
bin/doom
|
@ -44,7 +44,7 @@
|
||||||
"This is likely because this script (or its parent directory) is a symlink.\n"
|
"This is likely because this script (or its parent directory) is a symlink.\n"
|
||||||
"If you must use a symlink, you'll need to specify an EMACSDIR so Doom knows\n"
|
"If you must use a symlink, you'll need to specify an EMACSDIR so Doom knows\n"
|
||||||
"where to find itself. e.g.\n\n "
|
"where to find itself. e.g.\n\n "
|
||||||
(if (string-match "/fish$" (getenv "SHELL"))
|
(if (string-match-p "/fish$" (getenv "SHELL"))
|
||||||
"env EMACSDIR=~/.emacs.d doom"
|
"env EMACSDIR=~/.emacs.d doom"
|
||||||
"EMACSDIR=~/.emacs.d doom sync")
|
"EMACSDIR=~/.emacs.d doom sync")
|
||||||
"\n\n"
|
"\n\n"
|
||||||
|
@ -63,6 +63,15 @@
|
||||||
(load (expand-file-name "core/core.el" user-emacs-directory) nil t)
|
(load (expand-file-name "core/core.el" user-emacs-directory) nil t)
|
||||||
(require 'core-cli)
|
(require 'core-cli)
|
||||||
|
|
||||||
|
;; Use our own home-grown debugger to display and log errors + backtraces.
|
||||||
|
;; Control over its formatting is important, because Emacs produces
|
||||||
|
;; difficult-to-read debug information otherwise. By making its errors more
|
||||||
|
;; presentable (and storing them somewhere users can access later) we go a long
|
||||||
|
;; way toward making it easier for users to write better bug reports.
|
||||||
|
(setq debugger #'doom-cli--debugger
|
||||||
|
debug-on-error t
|
||||||
|
debug-ignored-errors nil)
|
||||||
|
|
||||||
;; HACK Load `cl' and site files manually to prevent polluting logs and stdout
|
;; HACK Load `cl' and site files manually to prevent polluting logs and stdout
|
||||||
;; with deprecation and/or file load messages.
|
;; with deprecation and/or file load messages.
|
||||||
(quiet! (if EMACS27+ (require 'cl))
|
(quiet! (if EMACS27+ (require 'cl))
|
||||||
|
@ -70,10 +79,11 @@
|
||||||
|
|
||||||
(kill-emacs
|
(kill-emacs
|
||||||
(pcase
|
(pcase
|
||||||
;; Process the arguments passed to this script. `doom-cli-execute' should
|
(catch 'exit
|
||||||
;; return a boolean, integer (error code) or throw an 'exit event, which we
|
;; Process the arguments passed to this script. `doom-cli-execute' should
|
||||||
;; handle specially.
|
;; return a boolean, integer (error code) or throw an 'exit event, which
|
||||||
(apply #'doom-cli-execute :doom (cdr (member "--" argv)))
|
;; we handle specially.
|
||||||
|
(apply #'doom-cli-execute :doom (cdr (member "--" argv))))
|
||||||
;; Any non-zero integer is treated as an error code.
|
;; Any non-zero integer is treated as an error code.
|
||||||
((and (pred integerp) code) code)
|
((and (pred integerp) code) code)
|
||||||
;; If, instead, we were given a list or string, copy these as shell script
|
;; If, instead, we were given a list or string, copy these as shell script
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
(load! "autoload/output")
|
(load! "autoload/output")
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
|
|
||||||
|
;; Create all our core directories to quell file errors.
|
||||||
|
(mapc (doom-rpartial #'make-directory 'parents)
|
||||||
|
(list doom-local-dir
|
||||||
|
doom-etc-dir
|
||||||
|
doom-cache-dir))
|
||||||
|
|
||||||
;; Ensure straight and the bare minimum is ready to go
|
;; Ensure straight and the bare minimum is ready to go
|
||||||
(require 'core-modules)
|
(require 'core-modules)
|
||||||
(require 'core-packages)
|
(require 'core-packages)
|
||||||
|
@ -453,8 +459,10 @@ with a different private module."
|
||||||
(when auto-accept-p
|
(when auto-accept-p
|
||||||
(setenv "YES" auto-accept-p)
|
(setenv "YES" auto-accept-p)
|
||||||
(print! (info "Confirmations auto-accept enabled")))
|
(print! (info "Confirmations auto-accept enabled")))
|
||||||
(setenv "__DOOMRESTART" "1")
|
(throw 'exit "__DOOMRESTART=1 $@"))
|
||||||
(throw 'exit :restart))
|
;; TODO Rotate logs out, instead of overwriting them?
|
||||||
|
(delete-file doom-cli-log-file)
|
||||||
|
(delete-file doom-cli-log-error-file)
|
||||||
(when help-p
|
(when help-p
|
||||||
(when command
|
(when command
|
||||||
(push command args))
|
(push command args))
|
||||||
|
@ -549,26 +557,6 @@ best to run Doom out of ~/.emacs.d and ~/.doom.d."
|
||||||
;;; Bootstrap
|
;;; Bootstrap
|
||||||
|
|
||||||
(doom-log "Initializing Doom CLI")
|
(doom-log "Initializing Doom CLI")
|
||||||
|
|
||||||
;; Use our own home-grown debugger to display and log errors + backtraces.
|
|
||||||
;; Control over its formatting is important, because Emacs produces
|
|
||||||
;; difficult-to-read debug information otherwise. By making its errors more
|
|
||||||
;; presentable (and storing them somewhere users can access them later) we go a
|
|
||||||
;; long way toward making it easier for users to write better bug reports.
|
|
||||||
(setq debugger #'doom-cli--debugger
|
|
||||||
debug-on-error t
|
|
||||||
debug-ignored-errors nil)
|
|
||||||
|
|
||||||
;; Clean slate for the next invocation
|
|
||||||
(delete-file doom-cli-log-file)
|
|
||||||
(delete-file doom-cli-log-error-file)
|
|
||||||
|
|
||||||
;; Create all our core directories to quell file errors
|
|
||||||
(mapc (doom-rpartial #'make-directory 'parents)
|
|
||||||
(list doom-local-dir
|
|
||||||
doom-etc-dir
|
|
||||||
doom-cache-dir))
|
|
||||||
|
|
||||||
(load! doom-module-init-file doom-private-dir t)
|
(load! doom-module-init-file doom-private-dir t)
|
||||||
(maphash (doom-module-loader doom-cli-file) doom-modules)
|
(maphash (doom-module-loader doom-cli-file) doom-modules)
|
||||||
(load! doom-cli-file doom-private-dir t)
|
(load! doom-cli-file doom-private-dir t)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue