~old/guile-porkbun

1ac3ceb9b83ce0b5f0430d5faa2f3ecf9e1dcf97 — Olivier Dion a month ago d23213f
bin/porkbun: Add poll option

Signed-off-by: Olivier Dion <olivier.dion@polymtl.ca>
1 files changed, 19 insertions(+), 11 deletions(-)

M bin/porkbun
M bin/porkbun => bin/porkbun +19 -11
@@ 59,7 59,7 @@ COMMAND:
")
  (exit error-code))

(define* (main% arguments #:key key secret)
(define* (main% arguments #:key key secret poll #:rest rest)
  (unless key
    (eprintf "Missing API key.")
    (usage EXIT_FAILURE))


@@ 68,15 68,20 @@ COMMAND:
    (usage EXIT_FAILURE))
  (parameterize ((porkbun:current-api-key
                  (porkbun:make-api-key key secret)))
    (match arguments
      (("update-dns" domain)
       (update-dns domain (porkbun:ping)))
      ((command rest ...)
       (eprintf "Unknown command ~a" command)
       (usage EXIT_FAILURE))
      (_
       (eprintf "Missing command")
       (usage EXIT_FAILURE)))))
    (let ((proc (match arguments
                  (("update-dns" domain)
                   (lambda () (update-dns domain (porkbun:ping))))
                  ((command rest ...)
                   (eprintf "Unknown command ~a" command)
                   (usage EXIT_FAILURE))
                  (_
                   (eprintf "Missing command")
                   (usage EXIT_FAILURE)))))
      (let lp ()
        (proc)
        (when poll
          (sleep poll)
          (lp))))))

(define (main args)



@@ 89,7 94,10 @@ COMMAND:
               (values (acons 'key value options) args)))
     (option '(#\s "secret") #t #f
             (lambda (opt name value options args)
               (values (acons 'secret value options) args)))))
               (values (acons 'secret value options) args)))
     (option '("poll") #t #f
             (lambda (opt ame value options args)
               (values (acons 'poll (string->number value) options) args)))))
  (call-with-values
      (lambda ()
        (args-fold (cdr args)