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.

44 lines
1.4 KiB

#! /usr/bin/env sh
exec guile -e '(@ (read-bible) main)' -s "$0" "$@"
!#
(define-module (read-bible)
#:use-module (bible-tools)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (main))
(define (verse->string v)
(string-append (book v) " " (chapter v) ":" (verse v) "\t" (text v)))
(define (print-text txt)
(for-each (lambda (str) (display str) (newline))
(map verse->string txt)))
(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 (version)
(display "read-bible v1.0.0\n"))
(define (main args)
(define flag? (cut member <> args))
(define get (compose cadr flag?))
(define-syntax conf
(syntax-rules (else)
((_ (f e)... (else g)) (cond ((flag? f) e)... (else g)))))
(if (< (length args) 2)
(help)
(with-bible (cadr args)
(conf ("-h" (help))
("-v" (version))
("-b" (if (flag? "-c")
(call-with-chapter (get "-b") (get "-c")
print-text)
(call-with-book (get "-b") print-text)))
(else (help))))))