Fix UNIX cli error-handling
… I made a silly, brainless mistake here. :P
This commit is contained in:
parent
e765f14583
commit
b0edcf78a4
|
@ -36,8 +36,7 @@
|
||||||
;; nil → nil
|
;; nil → nil
|
||||||
(defun main ()
|
(defun main ()
|
||||||
"Actual invocation of the program. This is what you should set as :toplevel."
|
"Actual invocation of the program. This is what you should set as :toplevel."
|
||||||
(error-print
|
(handler-case
|
||||||
99 ""
|
|
||||||
(multiple-value-bind (opts free) (opts:get-opts)
|
(multiple-value-bind (opts free) (opts:get-opts)
|
||||||
(when-opt opts :help (help))
|
(when-opt opts :help (help))
|
||||||
(let* ((input-stream (choose-input-stream (car free)))
|
(let* ((input-stream (choose-input-stream (car free)))
|
||||||
|
@ -50,7 +49,9 @@
|
||||||
(mirror-img:mirror-img
|
(mirror-img:mirror-img
|
||||||
input-stream
|
input-stream
|
||||||
download-dir
|
download-dir
|
||||||
:url-dir url-base))))))
|
:url-dir url-base))))
|
||||||
|
(error (c)
|
||||||
|
(error-print 99 nil c))))
|
||||||
|
|
||||||
(opts:define-opts
|
(opts:define-opts
|
||||||
(:name :help
|
(:name :help
|
||||||
|
@ -69,6 +70,10 @@
|
||||||
(error (c)
|
(error (c)
|
||||||
(error-print 11 "Could not access or create directory." c))))))
|
(error-print 11 "Could not access or create directory." c))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;; Output
|
||||||
|
;;; ————————————————————————————————————————
|
||||||
;; number stream → nil
|
;; number stream → nil
|
||||||
(defun help (&optional (exit-code 0) (stream *standard-output*))
|
(defun help (&optional (exit-code 0) (stream *standard-output*))
|
||||||
"Prints help message and dies."
|
"Prints help message and dies."
|
||||||
|
@ -82,7 +87,7 @@
|
||||||
;; number string condition → nil
|
;; number string condition → nil
|
||||||
(defun error-print (exit-code &optional message condition)
|
(defun error-print (exit-code &optional message condition)
|
||||||
"Print an error-message and exit."
|
"Print an error-message and exit."
|
||||||
(format *error-output* "~@[~A~%~]~@[~A~%~]" message condition)
|
(format *error-output* "~@[~A~%~]~@[Error: ~A~%~]" message condition)
|
||||||
(unix-opts:exit exit-code))
|
(unix-opts:exit exit-code))
|
||||||
|
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue