123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/run/current-system/profile/bin/guile \
- --no-auto-compile -e (dnscheck) -s
- !#
- ;;;; dnscheck --- https://github.com/NorfairKing/dnscheck wrapper
- ;;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
- ;;;; Released under the GNU GPLv3 or any later version.
- (define-module (dnscheck)
- #:use-module (json)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-37)
- #:export (main))
- ;;; Commentary:
- ;;;
- ;;; DESCRIPTION
- ;;;
- ;;; Code:
- (define %options
- (let ((display-and-exit-proc (lambda (msg)
- (lambda (opt name arg loads)
- (display msg) (quit)))))
- (list (option '(#\v "version") #f #f
- (display-and-exit-proc "dnscheck version 0.0.1\n"))
- (option '(#\h "help") #f #f
- (display-and-exit-proc
- "Usage: dnscheck ...\n")))))
- (define %default-options
- '())
- (define %home
- (and=> (getenv "HOME")
- (lambda (home)
- home)))
- (define (main args)
- (define opts
- (args-fold (cdr (program-arguments))
- %options
- (lambda (opt name arg loads)
- (error "Unrecognized option `~A'" name))
- (lambda (op loads)
- (cons op loads))
- %default-options))
- (define json-filename
- (port-filename (mkstemp "/tmp/dnscheck-json-XXXXXX")))
- (with-output-to-file json-filename
- (lambda _
- (display (scm->json-string (load (last args))))))
- (system* (string-append %home "/.nix-profile/bin/dnscheck") json-filename)
- (delete-file json-filename))
- ;;; dnscheck ends here
|