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.

35 lines
1.1 KiB

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