2020-08-24 00:36:52 -04:00
|
|
|
;;; core/core-cli.el --- -*- lexical-binding: t; no-byte-compile: t; -*-
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
|
2018-05-24 19:03:36 +02:00
|
|
|
(defvar doom-auto-accept (getenv "YES")
|
|
|
|
"If non-nil, Doom will auto-accept any confirmation prompts during batch
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
commands like `doom-cli-packages-install', `doom-cli-packages-update' and
|
2018-06-17 21:35:58 +02:00
|
|
|
`doom-packages-autoremove'.")
|
2018-05-20 12:21:13 +02:00
|
|
|
|
2020-01-09 03:31:05 -05:00
|
|
|
(defvar doom-auto-discard (getenv "FORCE")
|
|
|
|
"If non-nil, discard all local changes while updating.")
|
|
|
|
|
2020-05-25 03:09:46 -04:00
|
|
|
(defvar doom-cli-file "cli"
|
|
|
|
"The basename of CLI config files for modules.
|
|
|
|
|
|
|
|
These are loaded when a Doom's CLI starts up. There users and modules can define
|
|
|
|
additional CLI commands, or reconfigure existing ones to better suit their
|
|
|
|
purpose.")
|
|
|
|
|
2020-08-24 00:36:52 -04:00
|
|
|
(defvar doom-cli-log-file (concat doom-local-dir "doom.log")
|
2021-03-12 17:55:41 -05:00
|
|
|
"Where to write the extended output to.")
|
2020-08-24 00:36:52 -04:00
|
|
|
|
|
|
|
(defvar doom-cli-log-error-file (concat doom-local-dir "doom.error.log")
|
2021-03-12 17:55:41 -05:00
|
|
|
"Where to write the last backtrace to.")
|
2020-08-24 00:36:52 -04:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
(defvar doom--cli-log-buffer (generate-new-buffer " *doom log*"))
|
2019-07-21 15:39:45 +02:00
|
|
|
(defvar doom--cli-commands (make-hash-table :test 'equal))
|
|
|
|
(defvar doom--cli-groups (make-hash-table :test 'equal))
|
|
|
|
(defvar doom--cli-group nil)
|
|
|
|
|
2020-08-24 00:36:52 -04:00
|
|
|
(define-error 'doom-cli-error "There was an unexpected error" 'doom-error)
|
|
|
|
(define-error 'doom-cli-command-not-found-error "Could not find that command" 'doom-cli-error)
|
|
|
|
(define-error 'doom-cli-wrong-number-of-arguments-error "Wrong number of CLI arguments" 'doom-cli-error)
|
|
|
|
(define-error 'doom-cli-unrecognized-option-error "Not a recognized option" 'doom-cli-error)
|
|
|
|
(define-error 'doom-cli-deprecated-error "Command is deprecated" 'doom-cli-error)
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
2021-03-12 17:55:41 -05:00
|
|
|
;;; Bootstrap
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
(require 'seq)
|
|
|
|
(load! "autoload/process")
|
|
|
|
(load! "autoload/system")
|
|
|
|
(load! "autoload/plist")
|
|
|
|
(load! "autoload/files")
|
|
|
|
(load! "autoload/output")
|
2020-05-25 02:20:26 -04:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
(load! "cli/lib/debugger")
|
|
|
|
(load! "cli/lib/lib")
|
|
|
|
(load! "cli/lib/straight-hacks")
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
;; Use our own home-grown debugger so we can capture and store backtraces, make
|
|
|
|
;; them more presentable, and make it easier for users to produce better bug
|
|
|
|
;; reports!
|
|
|
|
(setq debugger #'doom-cli--debugger
|
|
|
|
debug-on-error t
|
|
|
|
debug-ignored-errors '(user-error))
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
;; 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))
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
;; Ensure straight and core packages are ready to go for CLI commands.
|
|
|
|
(require 'core-modules)
|
|
|
|
(require 'core-packages)
|
|
|
|
(doom-initialize-core-packages)
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2021-03-12 17:55:41 -05:00
|
|
|
;; Don't generate superfluous files when writing temp buffers
|
|
|
|
(setq make-backup-files nil)
|
|
|
|
;; Stop user configuration from interfering with package management
|
|
|
|
(setq enable-dir-local-variables nil)
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2021-05-12 14:50:59 -04:00
|
|
|
;; Default to using all cores, rather than half of them, since we compile things
|
|
|
|
;; ahead-of-time in a non-interactive session.
|
|
|
|
(defadvice! doom--comp-use-all-cores-a (&rest _)
|
|
|
|
:before #'comp-effective-async-max-jobs
|
|
|
|
(setq comp-num-cpus (doom-system-cpus)))
|
|
|
|
|
2020-01-09 03:31:05 -05:00
|
|
|
|
2020-08-24 00:36:52 -04:00
|
|
|
;;
|
|
|
|
;;; Entry point
|
|
|
|
|
|
|
|
(defcli! :doom
|
|
|
|
((help-p ["-h" "--help"] "Same as help command")
|
|
|
|
(auto-accept-p ["-y" "--yes"] "Auto-accept all confirmation prompts")
|
|
|
|
(debug-p ["-d" "--debug"] "Enables on verbose output")
|
|
|
|
(doomdir ["--doomdir" dir] "Use the private module at DIR (e.g. ~/.doom.d)")
|
|
|
|
(localdir ["--localdir" dir] "Use DIR as your local storage directory")
|
|
|
|
&optional command
|
|
|
|
&rest args)
|
|
|
|
"A command line interface for managing Doom Emacs.
|
|
|
|
|
|
|
|
Includes package management, diagnostics, unit tests, and byte-compilation.
|
|
|
|
|
|
|
|
This tool also makes it trivial to launch Emacs out of a different folder or
|
2020-10-08 13:11:00 -04:00
|
|
|
with a different private module.
|
|
|
|
|
|
|
|
Environment variables:
|
|
|
|
EMACSDIR Where to find the Doom Emacs repo (normally ~/.emacs.d)
|
|
|
|
DOOMDIR Where to find your private Doom config (normally ~/.doom.d)
|
|
|
|
DOOMLOCALDIR Where to store local files (normally ~/.emacs.d/.local)"
|
2020-08-24 00:36:52 -04:00
|
|
|
(condition-case e
|
2021-03-12 17:55:41 -05:00
|
|
|
(with-output-to! doom--cli-log-buffer
|
2020-08-24 00:36:52 -04:00
|
|
|
(catch 'exit
|
|
|
|
(when (and (not (getenv "__DOOMRESTART"))
|
|
|
|
(or doomdir
|
|
|
|
localdir
|
|
|
|
debug-p
|
|
|
|
auto-accept-p))
|
|
|
|
(when doomdir
|
|
|
|
(setenv "DOOMDIR" (file-name-as-directory doomdir))
|
|
|
|
(print! (info "DOOMDIR=%s") localdir))
|
|
|
|
(when localdir
|
|
|
|
(setenv "DOOMLOCALDIR" (file-name-as-directory localdir))
|
|
|
|
(print! (info "DOOMLOCALDIR=%s") localdir))
|
|
|
|
(when debug-p
|
|
|
|
(setenv "DEBUG" "1")
|
|
|
|
(print! (info "DEBUG=1")))
|
|
|
|
(when auto-accept-p
|
|
|
|
(setenv "YES" auto-accept-p)
|
|
|
|
(print! (info "Confirmations auto-accept enabled")))
|
2020-08-26 22:31:46 -04:00
|
|
|
(throw 'exit "__DOOMRESTART=1 $@"))
|
|
|
|
;; TODO Rotate logs out, instead of overwriting them?
|
|
|
|
(delete-file doom-cli-log-file)
|
|
|
|
(delete-file doom-cli-log-error-file)
|
2020-08-24 00:36:52 -04:00
|
|
|
(when help-p
|
|
|
|
(when command
|
|
|
|
(push command args))
|
|
|
|
(setq command "help"))
|
2021-05-17 22:29:50 -04:00
|
|
|
(cons
|
|
|
|
t (if (null command)
|
|
|
|
(doom-cli-execute "help")
|
|
|
|
(let ((start-time (current-time)))
|
|
|
|
(run-hooks 'doom-cli-pre-hook)
|
2021-05-24 17:32:46 -04:00
|
|
|
(unless (getenv "__DOOMRESTART")
|
|
|
|
(print! (start "Executing 'doom %s' %s")
|
|
|
|
(string-join
|
|
|
|
(cons (or (ignore-errors
|
|
|
|
(doom-cli-name (doom-cli-get command)))
|
|
|
|
command)
|
|
|
|
args)
|
|
|
|
" ")
|
|
|
|
(format-time-string "%Y-%m-%d %H:%M:%S")))
|
2021-05-23 21:40:01 -04:00
|
|
|
(print-group!
|
|
|
|
(when-let (result (apply #'doom-cli-execute command args))
|
|
|
|
(run-hooks 'doom-cli-post-hook)
|
|
|
|
(print! (success "Finished in %s")
|
|
|
|
(let* ((duration (float-time (time-subtract (current-time) before-init-time)))
|
|
|
|
(hours (/ (truncate duration) 60 60))
|
|
|
|
(minutes (- (/ (truncate duration) 60) (* hours 60)))
|
|
|
|
(seconds (- duration (* hours 60 60) (* minutes 60))))
|
|
|
|
(string-join
|
|
|
|
(delq
|
|
|
|
nil (list (unless (zerop hours) (format "%dh" hours))
|
|
|
|
(unless (zerop minutes) (format "%dm" minutes))
|
|
|
|
(format (if (> duration 60) "%ds" "%.4fs")
|
|
|
|
seconds))))))
|
|
|
|
result)))))))
|
2020-08-24 00:36:52 -04:00
|
|
|
;; TODO Not implemented yet
|
|
|
|
(doom-cli-command-not-found-error
|
|
|
|
(print! (error "Command 'doom %s' not recognized") (string-join (cdr e) " "))
|
|
|
|
(print! "\nDid you mean one of these commands?")
|
2020-08-24 23:22:57 -04:00
|
|
|
(apply #'doom-cli-execute "help" "--similar" (string-join (cdr e) " "))
|
2021-03-12 17:55:41 -05:00
|
|
|
5)
|
2020-08-24 00:36:52 -04:00
|
|
|
;; TODO Not implemented yet
|
|
|
|
(doom-cli-wrong-number-of-arguments-error
|
|
|
|
(cl-destructuring-bind (route opt arg n d) (cdr e)
|
|
|
|
(print! (error "doom %s: %S requires %d arguments, but %d given\n")
|
|
|
|
(mapconcat #'symbol-name route " ") arg n d)
|
|
|
|
(print-group!
|
|
|
|
(apply #'doom-cli-execute "help" (mapcar #'symbol-name route))))
|
2021-03-12 17:55:41 -05:00
|
|
|
6)
|
2020-08-24 00:36:52 -04:00
|
|
|
;; TODO Not implemented yet
|
|
|
|
(doom-cli-unrecognized-option-error
|
|
|
|
(let ((option (cadr e)))
|
|
|
|
(print! (error "Unrecognized option: %S") option)
|
|
|
|
(when (string-match "^--[^=]+=\\(.+\\)$" option)
|
|
|
|
(print! "The %S syntax isn't supported. Use '%s %s' instead."
|
|
|
|
option (car (split-string option "="))
|
|
|
|
(match-string 1 option))))
|
2021-03-12 17:55:41 -05:00
|
|
|
7)
|
2020-08-24 00:36:52 -04:00
|
|
|
;; TODO Not implemented yet
|
|
|
|
(doom-cli-deprecated-error
|
|
|
|
(cl-destructuring-bind (route . commands) (cdr e)
|
|
|
|
(print! (warn "The 'doom %s' command was removed and replaced with:\n")
|
|
|
|
(mapconcat #'symbol-name route " "))
|
|
|
|
(print-group!
|
|
|
|
(dolist (command commands)
|
|
|
|
(print! (info "%s") command))))
|
2021-03-12 17:55:41 -05:00
|
|
|
8)
|
2020-08-24 00:36:52 -04:00
|
|
|
(user-error
|
|
|
|
(print! (warn "%s") (cadr e))
|
2021-03-12 17:55:41 -05:00
|
|
|
9)))
|
2020-08-24 00:36:52 -04:00
|
|
|
|
|
|
|
|
2018-05-20 12:21:13 +02:00
|
|
|
;;
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
;;; CLI Commands
|
2019-05-01 19:12:52 -04:00
|
|
|
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
(load! "cli/help")
|
|
|
|
(load! "cli/install")
|
2020-08-24 00:36:52 -04:00
|
|
|
(load! "cli/sync")
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
(load! "cli/env")
|
|
|
|
(load! "cli/upgrade")
|
|
|
|
(load! "cli/packages")
|
|
|
|
(load! "cli/autoloads")
|
2019-07-21 15:39:45 +02:00
|
|
|
|
2019-07-28 01:32:16 +02:00
|
|
|
(defcligroup! "Diagnostics"
|
2019-07-21 15:39:45 +02:00
|
|
|
"For troubleshooting and diagnostics"
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
(load! "cli/doctor")
|
2019-07-21 15:39:45 +02:00
|
|
|
(load! "cli/debug")
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
|
|
|
|
;; Our tests are broken at the moment. Working on fixing them, but for now we
|
|
|
|
;; disable them:
|
|
|
|
;; (load! "cli/test")
|
|
|
|
)
|
|
|
|
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
(defcligroup! "Compilation"
|
|
|
|
"For compiling Doom and your config"
|
2019-07-21 15:39:45 +02:00
|
|
|
(load! "cli/byte-compile"))
|
2018-05-20 12:21:13 +02:00
|
|
|
|
2019-07-28 01:32:16 +02:00
|
|
|
(defcligroup! "Utilities"
|
2019-07-21 15:39:45 +02:00
|
|
|
"Conveniences for interacting with Doom externally"
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
(defcli! run (&rest args)
|
2019-07-21 15:39:45 +02:00
|
|
|
"Run Doom Emacs from bin/doom's parent directory.
|
2018-05-28 12:19:58 +02:00
|
|
|
|
Rewrite core-cli
Highlights:
- 'doom purge' now purges builds, elpa packages, and repos by default.
Regrafting repos is now opt-in with the -g/--regraft switches.
Negation flags have been added for elpa/repos: -e/--no-elpa and
-r/--no-repos.
- Removed 'doom rebuild' (it is now just 'doom build' or 'doom b').
- Removed 'doom build's -f flag, this is now the default. Added the -r
flag instead, which only builds packages that need rebuilding.
- 'doom update' now updates packages synchronously, but produces more
informative output about the updating process.
- Straight can now prompt in batch mode, which resolves a lot of issues
with 'doom update' (and 'doom upgrade') freezing indefinitely or
throwing repo branch errors.
- 'bin/doom's switches are now positional. Switches aimed at `bin/doom`
must precede any subcommands. e.g.
Do: 'doom -yd upgrade'
Don't do: 'doom upgrade -yd'
- Moved 'doom doctor' from bin/doom-doctor to core/cli/doctor, and
integrated core/doctor.el into it, as to avoid naming conflicts
between it and Emacs doctor.
- The defcli! macro now has a special syntax for declaring flags, their
arguments and descriptions.
Addresses #1981, #1925, #1816, #1721, #1322
2019-11-07 15:59:56 -05:00
|
|
|
All arguments are passed on to Emacs.
|
2018-06-11 23:20:45 +02:00
|
|
|
|
2019-07-21 15:39:45 +02:00
|
|
|
doom run
|
|
|
|
doom run -nw init.el
|
2018-06-11 23:20:45 +02:00
|
|
|
|
2019-07-21 15:39:45 +02:00
|
|
|
WARNING: this command exists for convenience and testing. Doom will suffer
|
|
|
|
additional overhead by being started this way. For the best performance, it is
|
2020-05-26 02:27:58 -04:00
|
|
|
best to run Doom out of ~/.emacs.d and ~/.doom.d."
|
2020-08-24 00:36:52 -04:00
|
|
|
(throw 'exit (cons invocation-name args))))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Bootstrap
|
|
|
|
|
|
|
|
(doom-log "Initializing Doom CLI")
|
|
|
|
(load! doom-module-init-file doom-private-dir t)
|
2020-08-25 06:01:35 -04:00
|
|
|
(maphash (doom-module-loader doom-cli-file) doom-modules)
|
2020-08-24 00:36:52 -04:00
|
|
|
(load! doom-cli-file doom-private-dir t)
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
|
2018-06-20 12:03:23 +02:00
|
|
|
(provide 'core-cli)
|
|
|
|
;;; core-cli.el ends here
|