summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2013-02-14 04:15:25 -0500
committerMark H Weaver <mhw@netris.org>2013-02-16 22:17:37 -0500
commite49951eb3e1e1a8e7bad6d7471483e70b0865352 (patch)
tree7924fec33724f1de6a1cdd0757c7ebe38c7bee6b /guix/ui.scm
parent040860152e63bbafb2eb3e93619e18d107c96b55 (diff)
Replace individual scripts with master 'guix' script.
* scripts/guix.in: New script. * Makefile.am (bin_SCRIPTS): Add 'scripts/guix'. Remove 'guix-build', 'guix-download', 'guix-import', 'guix-package', and 'guix-gc'. (MODULES): Add 'guix/scripts/build.scm', 'guix/scripts/download.scm', 'guix/scripts/import.scm', 'guix/scripts/package.scm', and 'guix/scripts/gc.scm'. * configure.ac (AC_CONFIG_FILES): Add 'scripts/guix'. Remove 'guix-build', 'guix-download', 'guix-import', 'guix-package', and 'guix-gc'. * guix-build.in, guix-download.in, guix-gc.in, guix-import.in, guix-package.in: Remove shell script boilerplate. Move to guix-COMMAND.in to guix/scripts/COMMAND.scm. Rename module from (guix-COMMAND) to (guix scripts COMMAND). Change "guix-COMMAND" to "guix COMMAND" in usage help string. * pre-inst-env.in: Add "@abs_top_builddir@/scripts" to the front of $PATH. Export $GUIX_UNINSTALLED. * tests/guix-build.sh, tests/guix-daemon.sh, tests/guix-download.sh, tests/guix-gc.sh, tests/guix-package.sh: Use "guix COMMAND" instead of "guix-COMMAND". * doc/guix.texi: Replace all occurrences of "guix-COMMAND" with "guix COMMAND". * po/POTFILES.in: Update.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm38
1 files changed, 37 insertions, 1 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index 4aa93de3b4..644a3070f6 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -30,6 +31,7 @@
#:export (_
N_
install-locale
+ initialize-guix
leave
show-version-and-exit
show-bug-report-information
@@ -38,7 +40,9 @@
location->string
fill-paragraph
string->recutils
- package->recutils))
+ package->recutils
+ run-guix-command
+ guix-main))
;;; Commentary:
;;;
@@ -62,6 +66,12 @@
(_ "warning: failed to install locale: ~a~%")
(strerror (system-error-errno args))))))
+(define (initialize-guix)
+ (install-locale)
+ (textdomain "guix")
+ (setvbuf (current-output-port) _IOLBF)
+ (setvbuf (current-error-port) _IOLBF))
+
(define-syntax-rule (leave fmt args ...)
"Format FMT and ARGS to the error port and exit."
(begin
@@ -210,4 +220,30 @@ WIDTH columns."
(and=> (package-description p) description->recutils))
(newline port))
+(define (show-guix-usage)
+ ;; TODO: Dynamically generate a summary of available commands.
+ (format (current-error-port)
+ (_ "Usage: guix COMMAND ARGS...~%")))
+
+(define (run-guix-command command . args)
+ ;; TODO: Gracefully report errors
+ (let* ((module (resolve-interface `(guix scripts ,command)))
+ (command-main (module-ref module
+ (symbol-append 'guix- command))))
+ (apply command-main args)))
+
+(define (guix-main arg0 . args)
+ (initialize-guix)
+ (let ()
+ (define (option? str) (string-prefix? "-" str))
+ (match args
+ (() (show-guix-usage) (exit 1))
+ (("--help") (show-guix-usage))
+ (("--version") (show-version-and-exit "guix"))
+ (((? option? arg1) args ...) (show-guix-usage) (exit 1))
+ ((command args ...)
+ (apply run-guix-command
+ (string->symbol command)
+ args)))))
+
;;; ui.scm ends here