~old/guile-porkbun

c05ebbf157d09c3eb94be8df6d0936b6388aa3cf — Olivier Dion a month ago 1ac3ceb
bin/porkbun: Add wait-until-network switch

Signed-off-by: Olivier Dion <olivier.dion@polymtl.ca>
2 files changed, 15 insertions(+), 4 deletions(-)

M .guix/modules/porkbun.scm
M bin/porkbun
M .guix/modules/porkbun.scm => .guix/modules/porkbun.scm +1 -1
@@ 65,7 65,7 @@
    (inputs
     (list guile-3.0 bash-minimal))
    (propagated-inputs
     (list guile-json-3 guile-gnutls))
     (list guile-json-4 guile-gnutls))
    (synopsis "")
    (description "")
    (home-page "")

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

(define* (main% arguments #:key key secret poll #:rest rest)
(define (wait-until-network)
  (catch #t
    (lambda ()
      (porkbun:ping))
    (lambda _ (sleep 1) (wait-until-network))))

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


@@ 68,6 74,8 @@ COMMAND:
    (usage EXIT_FAILURE))
  (parameterize ((porkbun:current-api-key
                  (porkbun:make-api-key key secret)))
    (when wait-until-network?
      (wait-until-network))
    (let ((proc (match arguments
                  (("update-dns" domain)
                   (lambda () (update-dns domain (porkbun:ping))))


@@ 96,8 104,11 @@ COMMAND:
             (lambda (opt name 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)))))
             (lambda (opt name value options args)
               (values (acons 'poll (string->number value) options) args)))
     (option '("wait-until-network") #f #f
             (lambda (opt name value options args)
               (values (acons 'wait-until-network? #t options) args)))))
  (call-with-values
      (lambda ()
        (args-fold (cdr args)