added comments detailing where argument checking was handled
updated error messages at top level
This commit is contained in:
parent
56f0efd7e9
commit
3646c8b13b
15
seanut.lisp
15
seanut.lisp
|
@ -110,6 +110,7 @@
|
|||
"binary entry point"
|
||||
(handle-user-abort
|
||||
(multiple-value-bind (opts args) (get-opts)
|
||||
;; --help
|
||||
(when (or (getf opts :help)
|
||||
(and (every #'null args)
|
||||
(every #'null opts)))
|
||||
|
@ -118,24 +119,28 @@
|
|||
:suffix (format nil *command-line-brief*
|
||||
*valid-media-types*))
|
||||
(uiop:quit 0))
|
||||
|
||||
|
||||
;; --version
|
||||
(when (getf opts :version)
|
||||
(quit-with-message 0 "seanut v~A" (seanut-version)))
|
||||
|
||||
;; --username/--password/--quick-connect/--token checking
|
||||
(unless (or (and (getf opts :username)
|
||||
(getf opts :password))
|
||||
(getf opts :quick-connect-p)
|
||||
(getf opts :token))
|
||||
(quit-with-message 1 "please provide an access token, username & password, or use quick connect"))
|
||||
|
||||
;; --media-type
|
||||
(unless (getf opts :media-type)
|
||||
(quit-with-message 1 "Please specify media type to download.~%~A ~{~A~^, ~}"
|
||||
"Supported media types are:"
|
||||
*valid-media-types*))
|
||||
|
||||
|
||||
;; DOMAIN SEARCH-TERM checking
|
||||
(when (some #'null args)
|
||||
(quit-with-message 1 "domain and/or media name not provided"))
|
||||
|
||||
|
||||
(destructuring-bind (domain search-term) args
|
||||
(let* ((authorization (or (and (getf opts :token) (generate-authorization (getf opts :token)))
|
||||
(generate-authorization (get-access-token domain opts))))
|
||||
|
@ -145,7 +150,7 @@
|
|||
(if (< 0 (length results))
|
||||
(loop :for item :across results
|
||||
:do (prompt-and-download domain authorization item opts))
|
||||
(quit-with-message 0 "No results found for ~A" search-term)))))
|
||||
(quit-with-message 0 "No results found for \"~A\"" search-term)))))
|
||||
|
||||
(error (e)
|
||||
(quit-with-message 1 "encountered error: ~A" e))))
|
||||
(quit-with-message 1 "error:~%~A" e))))
|
||||
|
|
Loading…
Reference in New Issue