diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2023-10-02 15:27:55 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2023-10-02 21:48:41 +0200 |
commit | 6e4283695dda186a16b1dc873c95a5973839f945 (patch) | |
tree | d967f8d44b82aaaec154d1ac9936a41393a15598 | |
parent | ed802e3e8da3440f5a07a49f2b3fb59ba240eeb4 (diff) |
cli: pair upload arguments
-rw-r--r-- | neocities/cli.scm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/neocities/cli.scm b/neocities/cli.scm index 066ecfd..3e80ae4 100644 --- a/neocities/cli.scm +++ b/neocities/cli.scm @@ -66,10 +66,15 @@ (format (current-error-port) "~A~&" (assoc-ref body "message"))))) (define (neocities-cmd-upload args) - ;; TODO - ;; - Multipart is not working - ;; - Input arguments have to be paired properly - (let-values (((response body) (neocities-upload %api '(("rando.txt" . "rando.txt"))))) + (define (pair-args args) + (map (lambda (i) + (cons (list-ref args (* 2 i)) (list-ref args (+ 1 (* 2 i))))) + (iota (/ (length args) 2)))) + + (when (or (> 1 (length args)) (not (= 0 (modulo (length args) 2)))) + (format (current-error-port) "USAGE: neocities upload LOCAL_FILE DESTINATION [...]~&") + (exit 1)) + (let-values (((response body) (neocities-upload %api (pair-args args)))) (if (neocities-success? body) (format #t "~A~&" (assoc-ref body "message")) (format (current-error-port) "~A~&" (assoc-ref body "message"))))) |