aboutsummaryrefslogtreecommitdiffstats
path: root/l
diff options
context:
space:
mode:
Diffstat (limited to 'l')
-rw-r--r--l/src/option.lisp8
1 files changed, 8 insertions, 0 deletions
diff --git a/l/src/option.lisp b/l/src/option.lisp
index 6965b71..3c266ea 100644
--- a/l/src/option.lisp
+++ b/l/src/option.lisp
@@ -1,19 +1,27 @@
+;;;; Command line options.
+
(in-package :extreload)
(defmacro when-option ((options option) &body body)
+ "When `option` is present in `options`, run `body`."
`(let ((value (getf ,options ,option)))
(when value
,@body)))
(defun exit-with-error (condition exit-code)
+ "Print the error associated with `condition` on standard error, then exit
+with code `exit-code`."
(format *error-output* "error: ~a~%" condition)
(opts:exit exit-code))
(defun handle-option-error (condition)
+ "Handle errors related to command line options. Prints the error specified by
+`condition` and exits with EX_USAGE."
(exit-with-error condition sysexits:+usage+))
(defun parse-options ()
+ "Parse command line options."
(multiple-value-bind (options free-args)
(handler-bind
((opts:unknown-option #'handle-option-error)