guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

13/20: ui: Add 'run-guix'.


From: Alex Kost
Subject: 13/20: ui: Add 'run-guix'.
Date: Tue, 18 Aug 2015 09:41:12 +0000

alezost pushed a commit to branch wip-emacs-popup-ui
in repository guix.

commit 87df7aab22ca1fe2145f2d2a89abd2d58825ec92
Author: Alex Kost <address@hidden>
Date:   Sun Aug 16 10:28:04 2015 +0300

    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 |   49 +++++++++++++++++++++++++++----------------------
 1 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 28d4b97..fff84ba 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <address@hidden>
 ;;; Copyright © 2013 Mark H Weaver <address@hidden>
 ;;; Copyright © 2013 Nikita Karetnikov <address@hidden>
-;;; Copyright © 2014 Alex Kost <address@hidden>
+;;; Copyright © 2014, 2015 Alex Kost <address@hidden>
 ;;; Copyright © 2014 Deck Pickard <address@hidden>
 ;;;
 ;;; 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
@@ -1031,31 +1032,35 @@ found."
     (parameterize ((program-name command))
       (apply command-main args))))
 
+(define (run-guix . args)
+  "Run guix command defined by command line ARGS."
+  (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]