From 87a79ae33d82b69133aa011da41afbf3d1f9e98d Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Fri, 10 Jun 2016 22:27:41 +0200 Subject: 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. --- bin/cuirass.in | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'bin/cuirass.in') 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 . (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"))))))))) -- cgit v1.2.3