diff options
author | Teddy Wing | 2021-02-02 01:04:08 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-02 01:04:08 +0100 |
commit | 3dbfff2478ca6b8b310d888a61fc08715ef35d1c (patch) | |
tree | 8b9e6d78f37c18941165a17e701f0a58c9d5bcf0 /l/src/option.lisp | |
parent | 074cb7d048c97484112474c0e2ee89a6a78660b7 (diff) | |
download | extreload-3dbfff2478ca6b8b310d888a61fc08715ef35d1c.tar.bz2 |
main: Handle command line argument parsing errors
Add an error handler that just prints the error messages from
'unix-opts' to standard error and exits with EX_USAGE.
Inspired by:
- http://lispcookbook.github.io/cl-cookbook/scripting.html#handling-malformed-or-missing-arguments
- https://github.com/libre-man/unix-opts/blob/0e61f34b2ecf62288437810d4abb31e572048b04/example/example.lisp
Diffstat (limited to 'l/src/option.lisp')
-rw-r--r-- | l/src/option.lisp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/l/src/option.lisp b/l/src/option.lisp index d828230..11f7f98 100644 --- a/l/src/option.lisp +++ b/l/src/option.lisp @@ -4,3 +4,8 @@ `(let ((value (getf ,options ,option))) (when value ,@body))) + +(defun handle-option-error (condition) + (format *error-output* "error: ~a~%" condition) + + (opts:exit 64)) |