ef64b5755bc1632f9e056fba5996d2eecdf7ded0
[jackhill/guix/guix.git] / guix / scripts / show.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (guix scripts show)
20 #:use-module (guix ui)
21 #:use-module (guix scripts package)
22 #:use-module ((guix scripts build)
23 #:select (%standard-build-options))
24 #:use-module (guix scripts)
25 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-26)
27 #:use-module (srfi srfi-37)
28 #:export (guix-show))
29
30 (define (show-help)
31 (display (G_ "Usage: guix show [OPTION] PACKAGE...
32 Show details about PACKAGE."))
33 (display (G_"
34 This is an alias for 'guix package --show='.\n"))
35 (newline)
36 (display (G_ "
37 -h, --help display this help and exit"))
38 (display (G_ "
39 -V, --version display version information and exit"))
40 (newline)
41 (display (G_ "
42 -L, --load-path=DIR prepend DIR to the package module search path"))
43 (newline)
44 (show-bug-report-information))
45
46 (define %options
47 ;; Specification of the command-line options.
48 (list (option '(#\h "help") #f #f
49 (lambda args
50 (show-help)
51 (exit 0)))
52 (option '(#\V "version") #f #f
53 (lambda args
54 (show-version-and-exit "guix show")))
55
56 (find (lambda (option)
57 (member "load-path" (option-names option)))
58 %standard-build-options)))
59
60 (define (guix-show . args)
61 (define (handle-argument arg result)
62 ;; Treat all non-option arguments as regexps.
63 (cons `(query show ,arg)
64 result))
65
66 (define opts
67 (args-fold* args %options
68 (lambda (opt name arg . rest)
69 (leave (G_ "~A: unrecognized option~%") name))
70 handle-argument
71 '()))
72
73 (unless (assoc-ref opts 'query)
74 (leave (G_ "missing arguments: no package to show~%")))
75
76 (guix-package* opts))