|
|
|
#! /usr/bin/env sh
|
|
|
|
exec guile -e main -s "$0" "$@"
|
|
|
|
!#
|
|
|
|
|
|
|
|
(use-modules (bible-tools bible-tools)
|
|
|
|
(bible-tools latex-export)
|
|
|
|
(srfi srfi-1)
|
|
|
|
(srfi srfi-26))
|
|
|
|
|
|
|
|
(define (help)
|
|
|
|
(display "Usage: bible2latex [-b book] [-c chapter]")
|
|
|
|
(display " [-h] [-v] [--bible b]\n")
|
|
|
|
(display "\t-b book\t\texport the book to latex\n")
|
|
|
|
(display "\t-c chapter\texport this chapter to latex\n")
|
|
|
|
(display "\t-h\t\tdisplay this help message\n")
|
|
|
|
(display "\t-v\t\tdisplay the current version\n")
|
|
|
|
(display "\t--bible b use this bible\n"))
|
|
|
|
|
|
|
|
(define (main args)
|
|
|
|
(define version "bible2latex v1.0.0\n")
|
|
|
|
(define pr (compose display as-latex))
|
|
|
|
(define flag? (cut member <> args))
|
|
|
|
(define get (compose cadr flag?))
|
|
|
|
(let-syntax ((conf
|
|
|
|
(syntax-rules (else)
|
|
|
|
((_ (f e)... (else g)) (cond ((flag? f) e)...
|
|
|
|
(else g))))))
|
|
|
|
(let ((bible (if (flag? "--bible") (get "--bible") "elb1871")))
|
|
|
|
(with-bible bible
|
|
|
|
(conf ("-h" (help))
|
|
|
|
("-v" (display version))
|
|
|
|
("-b" (if (flag? "-c")
|
|
|
|
(call-with-chapter (get "-b")
|
|
|
|
(get "-c") pr)
|
|
|
|
(call-with-book (get "-b") pr)))
|
|
|
|
(else pr))))))
|