mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
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.
This commit is contained in:
parent
00e219d1c9
commit
cdd5d6f95f
4 changed files with 12 additions and 15 deletions
|
@ -71,9 +71,6 @@ When SOURCE? is true, return the derivations of the package sources."
|
|||
`((system . ,(%current-system))
|
||||
(substitutes? . #t)))
|
||||
|
||||
(define (show-version)
|
||||
(display "guix-build (@PACKAGE_NAME@) @PACKAGE_VERSION@\n"))
|
||||
|
||||
(define (show-help)
|
||||
(display (_ "Usage: guix-build [OPTION]... PACKAGE-OR-DERIVATION...
|
||||
Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
|
||||
|
@ -113,8 +110,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(exit 0)))
|
||||
(option '(#\V "version") #f #f
|
||||
(lambda args
|
||||
(show-version)
|
||||
(exit 0)))
|
||||
(show-version-and-exit "guix-build")))
|
||||
|
||||
(option '(#\S "source") #f #f
|
||||
(lambda (opt name arg result)
|
||||
|
|
|
@ -88,9 +88,6 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
|
|||
;; Alist of default option values.
|
||||
`((format . ,bytevector->nix-base32-string)))
|
||||
|
||||
(define (show-version)
|
||||
(display "guix-download (@PACKAGE_NAME@) @PACKAGE_VERSION@\n"))
|
||||
|
||||
(define (show-help)
|
||||
(display (_ "Usage: guix-download [OPTION]... URL
|
||||
Download the file at URL, add it to the store, and print its store path
|
||||
|
@ -131,8 +128,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(exit 0)))
|
||||
(option '(#\V "version") #f #f
|
||||
(lambda args
|
||||
(show-version)
|
||||
(exit 0)))))
|
||||
(show-version-and-exit "guix-download")))))
|
||||
|
||||
|
||||
;;;
|
||||
|
|
|
@ -30,6 +30,7 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
|
|||
;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (guix-package)
|
||||
#:use-module (guix ui)
|
||||
#:use-module (guix store)
|
||||
#:use-module (guix derivations)
|
||||
#:use-module (guix packages)
|
||||
|
@ -192,9 +193,6 @@ all of PACKAGES, a list of name/version/output/path tuples."
|
|||
(format (current-error-port) fmt args ...)
|
||||
(exit 1)))
|
||||
|
||||
(define (show-version)
|
||||
(display "guix-package (@PACKAGE_NAME@) @PACKAGE_VERSION@\n"))
|
||||
|
||||
(define (show-help)
|
||||
(display (_ "Usage: guix-package [OPTION]... PACKAGES...
|
||||
Install, remove, or upgrade PACKAGES in a single transaction.\n"))
|
||||
|
@ -228,8 +226,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
|
|||
(exit 0)))
|
||||
(option '(#\V "version") #f #f
|
||||
(lambda args
|
||||
(show-version)
|
||||
(exit 0)))
|
||||
(show-version-and-exit "guix-package")))
|
||||
|
||||
(option '(#\i "install") #t #f
|
||||
(lambda (opt name arg result)
|
||||
|
|
|
@ -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 @@ (define-syntax-rule (leave fmt args ...)
|
|||
(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)
|
||||
|
|
Loading…
Reference in a new issue