diff options
author | Teddy Wing | 2021-02-03 00:23:16 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-03 00:23:16 +0100 |
commit | 8e11ddad215279411560838917220301e13148fd (patch) | |
tree | 28130f31dfd696c03c1c7f305d8e8cec1c2df28b /l/src/option.lisp | |
parent | 75b5d75523d36336af810207c3363044020bba17 (diff) | |
download | extreload-8e11ddad215279411560838917220301e13148fd.tar.bz2 |
main: Move option parsing code to new function `parse-options`
Make a new function `parse-options` that parses the command line options
and returns a `config` object. We'll use that object instead of
`options` in `main`. Cleans up the `main` function a bit.
Currently, we just print the `config` object to ensure we're storing the
proper values.
Followed Practical Common Lisp's example to implement `print-object` so
we can see the contents of its slots:
http://www.gigamonkeys.com/book/practical-a-spam-filter.html#the-heart-of-a-spam-filter
Still need to implement error checking for a missing `--socket-url`
option.
Diffstat (limited to 'l/src/option.lisp')
-rw-r--r-- | l/src/option.lisp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/l/src/option.lisp b/l/src/option.lisp index 11f7f98..a294325 100644 --- a/l/src/option.lisp +++ b/l/src/option.lisp @@ -9,3 +9,31 @@ (format *error-output* "error: ~a~%" condition) (opts:exit 64)) + +(defun parse-options () + (multiple-value-bind (options free-args) + (handler-bind + ((opts:unknown-option #'handle-option-error) + (opts:missing-arg #'handle-option-error) + (opts:arg-parser-failed #'handle-option-error) + (opts:missing-required-option #'handle-option-error)) + + (opts:get-opts)) + + (when-option (options :help) + (opts:describe + :usage-of "extreload" + :args "EXTENSION_ID...") + + (opts:exit 64)) + + (when-option (options :version) + (format t "~a~%" (asdf:component-version (asdf:find-system :extreload))) + + (opts:exit 0)) + + ; (if ) ;; If no socket URL, error 64 + + (make-instance 'config + :socket-url (getf options :socket-url) + :extension-ids free-args))) |