Fix UNIX cli error-handling
… I made a silly, brainless mistake here. :P
This commit is contained in:
parent
e765f14583
commit
b0edcf78a4
|
@ -36,21 +36,22 @@
|
||||||
;; 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)))
|
(url-base (or (getf opts :url-base) (getf opts :download-dir) "mirror/"))
|
||||||
(url-base (or (getf opts :url-base) (getf opts :download-dir) "mirror/"))
|
(download-dir (or (getf opts :download-dir) url-base)))
|
||||||
(download-dir (or (getf opts :download-dir) url-base)))
|
(when (not input-stream)
|
||||||
(when (not input-stream)
|
(error-print 1 "No HTML file provided. See --help for more information."))
|
||||||
(error-print 1 "No HTML file provided. See --help for more information."))
|
(format
|
||||||
(format
|
't
|
||||||
't
|
(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