From 6e4283695dda186a16b1dc873c95a5973839f945 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Mon, 2 Oct 2023 15:27:55 +0200 Subject: cli: pair upload arguments --- neocities/cli.scm | 13 +++++++++---- 1 file 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"))))) -- cgit v1.2.3