From caa6732e967ef4e397533d1cff9ba5626b2b4131 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sun, 16 Aug 2015 10:28:04 +0300 Subject: 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. --- guix/ui.scm | 51 +++++++++++++++++++++++++++++---------------------- 1 file 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 ;;; Copyright © 2013 Mark H Weaver ;;; Copyright © 2013 Nikita Karetnikov -;;; Copyright © 2014 Alex Kost +;;; Copyright © 2014, 2015 Alex Kost ;;; Copyright © 2014 Deck Pickard ;;; ;;; 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 -- cgit v1.2.3