You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

#! /usr/bin/env sh
exec guile -e '(@ (read-bible) main)' -s "$0" "$@"
!#
(define-module (read-bible)
2 years ago
#:use-module (bible-tools bible-tools)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (main))
2 years ago
(define (v->str v)
(string-append (book v) " " (chapter v) ":" (verse v)
"\t" (text v)))
(define (help)
(display "Usage: read-bible bible [-b book] [-c chapter] [-h] [-v]\n")
(display "\t-b book\t\tthe book to read\n")
(display "\t-c chapter\tthe chapter to read\n")
(display "\t-h\t\tdisplay this help message\n")
(display "\t-v\t\tdisplay the current version\n"))
(define (main args)
2 years ago
(define (pr t)
(map (lambda (str) (display str) (newline)) (map v->str t)))
(define version (cut display "read-bible v1.0.0\n"))
(define flag? (cut member <> args))
(define get (compose cadr flag?))
(define-syntax conf
(syntax-rules (else)
2 years ago
((_ (f e)...) (cond ((flag? f) e)... (else (help))))))
(if (< (length args) 2)
(help)
(with-bible (cadr args)
(conf ("-h" (help))
("-v" (version))
("-b" (if (flag? "-c")
2 years ago
(call-with-chapter (get "-b")
(get "-c") pr)
(call-with-book (get "-b") pr)))))))