show.scm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. (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-26)
  26. #:use-module (srfi srfi-37)
  27. #:export (guix-show))
  28. (define (show-help)
  29. (display (G_ "Usage: guix show [OPTION] PACKAGE...
  30. Show details about PACKAGE."))
  31. (display (G_"
  32. This is an alias for 'guix package --show='.\n"))
  33. (newline)
  34. (display (G_ "
  35. -h, --help display this help and exit"))
  36. (display (G_ "
  37. -V, --version display version information and exit"))
  38. (newline)
  39. (display (G_ "
  40. -L, --load-path=DIR prepend DIR to the package module search path"))
  41. (newline)
  42. (show-bug-report-information))
  43. (define %options
  44. ;; Specification of the command-line options.
  45. (list (option '(#\h "help") #f #f
  46. (lambda args
  47. (show-help)
  48. (exit 0)))
  49. (option '(#\V "version") #f #f
  50. (lambda args
  51. (show-version-and-exit "guix show")))
  52. (find (lambda (option)
  53. (member "load-path" (option-names option)))
  54. %standard-build-options)))
  55. (define (guix-show . args)
  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. (args-fold* args %options
  62. (lambda (opt name arg . rest)
  63. (leave (G_ "~A: unrecognized option~%") name))
  64. handle-argument
  65. '()))
  66. (unless (assoc-ref opts 'query)
  67. (leave (G_ "missing arguments: no package to show~%")))
  68. (guix-package* opts))