diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2016-06-10 22:27:41 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2016-06-10 23:39:01 +0200 |
commit | 87a79ae33d82b69133aa011da41afbf3d1f9e98d (patch) | |
tree | 6cf54d56d5da4ad6ba77667d69d5c7d703ffa75a /bin/cuirass.in | |
parent | 8fb2983dcee4fec94bcc78ca4bc0f33eb5560665 (diff) | |
download | cuirass-87a79ae33d82b69133aa011da41afbf3d1f9e98d.tar cuirass-87a79ae33d82b69133aa011da41afbf3d1f9e98d.tar.gz |
cuirass: Add command line options.
* bin/cuirass.in (show-help, %options): new variables.
(main): Adapt.
* src/cuirass/ui.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
Diffstat (limited to 'bin/cuirass.in')
-rw-r--r-- | bin/cuirass.in | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/bin/cuirass.in b/bin/cuirass.in index 91d74a5..2683f6b 100644 --- a/bin/cuirass.in +++ b/bin/cuirass.in @@ -22,8 +22,26 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>. (use-modules (cuirass base) + (cuirass ui) + (ice-9 getopt-long) (ice-9 match)) +(define* (show-help #:optional (prog (program-name))) + (simple-format #t "Usage: ~a [OPTIONS] [CACHEDIR]" prog) + (display " +Run Guix job from a git repository cloned in CACHEDIR. + + -I, --interval[=]N Wait N seconds between each evaluation + -V, --version Display version + -h, --help Display this help message") + (newline) + (show-package-information)) + +(define %options + `((interval (single-char #\I) (value #t)) + (version (single-char #\V) (value #f)) + (help (single-char #\h) (value #f)))) + (define %guix-repository (make-parameter "git://git.savannah.gnu.org/guix.git")) @@ -92,12 +110,22 @@ DIR if required." ;;; (define* (main #:optional (args (command-line))) - (match args - ((program interval) - (let ((cachedir (getenv "CUIRASS_CACHEDIR"))) - (while #t - (pull-changes cachedir) - (compile cachedir) - (evaluate cachedir) - (sleep (string->number interval))))) - (_ (main (list (car args) "60"))))) + (let ((opts (getopt-long args %options)) + (progname "cuirass")) + (cond + ((option-ref opts 'help #f) + (show-help progname) + (exit 0)) + ((option-ref opts 'version #f) + (show-version progname) + (exit 0)) + (else + (let* ((args (option-ref opts '() #f)) + (cachedir (if (null? args) + (getenv "CUIRASS_CACHEDIR") + (car args)))) + (while #t + (pull-changes cachedir) + (compile cachedir) + (evaluate cachedir) + (sleep (string->number (option-ref opts 'interval "60"))))))))) |