show.scm 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019, 2021 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. (define-module (guix scripts show)
  19. #:use-module (guix ui)
  20. #:use-module (guix scripts package)
  21. #:use-module ((guix scripts build)
  22. #:select (%standard-build-options))
  23. #:use-module (guix scripts)
  24. #:use-module (srfi srfi-1)
  25. #:use-module (srfi srfi-37)
  26. #:export (guix-show))
  27. (define (show-help)
  28. (display (G_ "Usage: guix show [OPTION] PACKAGE...
  29. Show details about PACKAGE."))
  30. (display (G_"
  31. This is an alias for 'guix package --show='.\n"))
  32. (newline)
  33. (display (G_ "
  34. -h, --help display this help and exit"))
  35. (display (G_ "
  36. -V, --version display version information and exit"))
  37. (newline)
  38. (display (G_ "
  39. -L, --load-path=DIR prepend DIR to the package module search path"))
  40. (newline)
  41. (show-bug-report-information))
  42. (define %options
  43. ;; Specification of the command-line options.
  44. (list (option '(#\h "help") #f #f
  45. (lambda args
  46. (show-help)
  47. (exit 0)))
  48. (option '(#\V "version") #f #f
  49. (lambda args
  50. (show-version-and-exit "guix show")))
  51. (find (lambda (option)
  52. (member "load-path" (option-names option)))
  53. %standard-build-options)))
  54. (define-command (guix-show . args)
  55. (synopsis "show information about packages")
  56. (define (handle-argument arg result)
  57. ;; Treat all non-option arguments as regexps.
  58. (cons `(query show ,arg)
  59. result))
  60. (define opts
  61. (parse-command-line args %options (list (list))
  62. #:build-options? #f
  63. #:argument-handler handle-argument))
  64. (unless (assoc-ref opts 'query)
  65. (leave (G_ "missing arguments: no package to show~%")))
  66. (guix-package* (reverse opts)))