diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-11-03 21:19:43 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-11-03 21:19:43 +0100 |
commit | cdd5d6f95f416078509bce509b25c7c854da34a2 (patch) | |
tree | 41801084dc6c6b461d4b87192f1c581b08dbc60e /guix | |
parent | 00e219d1c98e55dd1b6c6af00ae73c23ed52583e (diff) | |
download | gnu-guix-cdd5d6f95f416078509bce509b25c7c854da34a2.tar gnu-guix-cdd5d6f95f416078509bce509b25c7c854da34a2.tar.gz |
ui: Factorize `--version'.
* guix/ui.scm (show-version-and-exit): New procedure.
* guix-build.in (show-version): Remove.
(%options)["version"]: Use `show-version-and-exit'.
* guix-download.in: Likewise.
* guix-package.in: Likewise.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/ui.scm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index cb78a21bd8..447c3a9a9f 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -19,12 +19,14 @@ (define-module (guix ui) #:use-module (guix utils) #:use-module (guix store) + #:use-module (guix config) #:use-module (guix packages) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:export (_ N_ leave + show-version-and-exit call-with-error-handling with-error-handling)) @@ -46,6 +48,12 @@ (format (current-error-port) fmt args ...) (exit 1))) +(define* (show-version-and-exit #:optional (command (car (command-line)))) + "Display version information for COMMAND and `(exit 0)'." + (simple-format #t "~a (~a) ~a~%" + command %guix-package-name %guix-version) + (exit 0)) + (define (call-with-error-handling thunk) "Call THUNK within a user-friendly error handler." (guard (c ((package-input-error? c) |