77 --log-filename FILENAME file name of the log file
88 -i, --interface INTERFACE interface to use, either sdl2 or ncurses
99 -v, --version print the version number and exit
10- -h, --help display this help and exit"
10+ -h, --help display this help and exit
11+ -e, --eval FORM common lisp form (in quotes) to evaluate on startup"
1112 " Help output for cli" )
1213
1314(defun show-help ()
@@ -23,22 +24,26 @@ Options:
2324 (without-init-file nil )
2425 (log-filename nil )
2526 (interface nil )
26- (filenames ' ()))
27+ (filenames ' ())
28+ (eval-form-str nil ))
2729
28- (defun use-spash -screen-p (args)
30+ (defun use-splash -screen-p (args)
2931 (null (command-line-arguments-filenames args)))
3032
3133(defun command-line-arguments-error (fmt &rest args)
3234 (error ' command-line-arguments-error :format-control fmt :format-arguments args))
3335
3436(defun parse-args (args)
37+ " returns a `command-line-arguments` that represents the arguments passed in from `args`.
38+ `args` should be a list of strings (from `uiop:command-line-arguments`)."
3539 (let ((help nil )
3640 (debug nil )
3741 (version nil )
3842 (without-init-file nil )
3943 (log-filename nil )
4044 (interface nil )
41- (filenames ' ()))
45+ (filenames ' ())
46+ (eval-form-str nil ))
4247 (loop :while args
4348 :for arg := (pop args)
4449 :do (cond ((member arg ' (" -h" " --help" ) :test #' equal )
@@ -60,6 +65,9 @@ Options:
6065 (command-line-arguments-error " Please specify an interface to use." ))))
6166 ((member arg ' (" -v" " --version" ) :test #' equal )
6267 (setf version t ))
68+ ((member arg ' (" -e" " --eval" ) :test #' equal )
69+ ; ; assumes that FORM follows --eval and is in quotes.
70+ (setf eval-form-str (pop args)))
6371 ((or (stringp arg) (pathnamep arg))
6472 (push arg filenames))
6573 (t
@@ -70,12 +78,24 @@ Options:
7078 :without-init-file without-init-file
7179 :log-filename log-filename
7280 :interface interface
73- :filenames (nreverse filenames))))
81+ :filenames (nreverse filenames)
82+ :eval-form-str eval-form-str)))
7483
7584(defun apply-args (args)
7685 (declare (command-line-arguments args))
77- (if (and (use-spash-screen-p args)
86+
87+ (if (and (use-splash-screen-p args)
7888 *splash-function* )
7989 (funcall *splash-function* )
8090 (loop :for filename :in (command-line-arguments-filenames args)
81- :do (uiop :symbol-call :lem :find-file (merge-pathnames filename (uiop :getcwd))))))
91+ :do (uiop :symbol-call :lem :find-file (merge-pathnames filename (uiop :getcwd)))))
92+
93+
94+ (let (form-str form)
95+ (setf form-str (command-line-arguments-eval-form-str args))
96+ (when form-str
97+ (setf form (read-from-string form-str nil ))
98+
99+ (if form
100+ (eval form)
101+ (editor-error " WARNING: -e/--eval supplied, but no form was provided!" )))))
0 commit comments