summaryrefslogtreecommitdiff
path: root/guix/ui.scm
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2015-08-16 10:28:04 +0300
committerAlex Kost <alezost@gmail.com>2015-08-30 18:26:02 +0300
commitcaa6732e967ef4e397533d1cff9ba5626b2b4131 (patch)
tree5fcc781df3fc8d7189a9e906b8c4aa2f669aae3a /guix/ui.scm
parent51dac383392a723aa77b0496cf12c593b013cb2b (diff)
ui: Add 'run-guix'.
* guix/ui.scm (guix-main): Move the code to run guix command line to ... (run-guix): ...here. New procedure. Export it.
Diffstat (limited to 'guix/ui.scm')
-rw-r--r--guix/ui.scm51
1 files changed, 29 insertions, 22 deletions
diff --git a/guix/ui.scm b/guix/ui.scm
index a6d4fd10cf..8de8e3c863 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -77,6 +77,7 @@
args-fold*
parse-command-line
run-guix-command
+ run-guix
program-name
guix-warning-port
warning
@@ -1032,31 +1033,37 @@ found."
(parameterize ((program-name command))
(apply command-main args))))
+(define (run-guix . args)
+ "Run the 'guix' command defined by command line ARGS.
+Unlike 'guix-main', this procedure assumes that locale, i18n support,
+and signal handling has already been set up."
+ (define option? (cut string-prefix? "-" <>))
+
+ (match args
+ (()
+ (format (current-error-port)
+ (_ "guix: missing command name~%"))
+ (show-guix-usage))
+ ((or ("-h") ("--help"))
+ (show-guix-help))
+ (("--version")
+ (show-version-and-exit "guix"))
+ (((? option? o) args ...)
+ (format (current-error-port)
+ (_ "guix: unrecognized option '~a'~%") o)
+ (show-guix-usage))
+ (("help" args ...)
+ (show-guix-help))
+ ((command args ...)
+ (apply run-guix-command
+ (string->symbol command)
+ args))))
+
(define guix-warning-port
(make-parameter (current-warning-port)))
(define (guix-main arg0 . args)
(initialize-guix)
- (let ()
- (define (option? str) (string-prefix? "-" str))
- (match args
- (()
- (format (current-error-port)
- (_ "guix: missing command name~%"))
- (show-guix-usage))
- ((or ("-h") ("--help"))
- (show-guix-help))
- (("--version")
- (show-version-and-exit "guix"))
- (((? option? o) args ...)
- (format (current-error-port)
- (_ "guix: unrecognized option '~a'~%") o)
- (show-guix-usage))
- (("help" args ...)
- (show-guix-help))
- ((command args ...)
- (apply run-guix-command
- (string->symbol command)
- args)))))
+ (apply run-guix args))
;;; ui.scm ends here