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.
34 lines
1.1 KiB
34 lines
1.1 KiB
#! /usr/bin/env sh |
|
exec guile -e main -s "$0" "$@" |
|
!# |
|
|
|
(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) |
|
(define (pr t) |
|
(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?)) |
|
(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))))))))
|
|
|