remove.scm 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
  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 remove)
  19. #:use-module (guix ui)
  20. #:use-module (guix scripts package)
  21. #:use-module (guix scripts build)
  22. #:use-module (guix scripts)
  23. #:use-module (srfi srfi-1)
  24. #:use-module (srfi srfi-26)
  25. #:use-module (srfi srfi-37)
  26. #:export (guix-remove))
  27. (define (show-help)
  28. (display (G_ "Usage: guix remove [OPTION] PACKAGES...
  29. Remove the given PACKAGES.
  30. This is an alias for 'guix package -r'.\n"))
  31. (display (G_ "
  32. -p, --profile=PROFILE use PROFILE instead of the user's default profile"))
  33. ;; '--bootstrap' not shown here.
  34. (display (G_ "
  35. -v, --verbosity=LEVEL use the given verbosity LEVEL"))
  36. (newline)
  37. (show-build-options-help)
  38. (newline)
  39. (display (G_ "
  40. -h, --help display this help and exit"))
  41. (display (G_ "
  42. -V, --version display version information and exit"))
  43. (newline)
  44. (show-bug-report-information))
  45. (define %options
  46. ;; Specification of the command-line options.
  47. (cons* (option '(#\h "help") #f #f
  48. (lambda args
  49. (show-help)
  50. (exit 0)))
  51. (option '(#\V "version") #f #f
  52. (lambda args
  53. (show-version-and-exit "guix remove")))
  54. ;; Preserve some of the 'guix package' options.
  55. (append (filter (lambda (option)
  56. (any (cut member <> (option-names option))
  57. '("profile" "dry-run" "verbosity" "bootstrap")))
  58. %package-options)
  59. %standard-build-options)))
  60. (define-command (guix-remove . args)
  61. (synopsis "remove installed packages")
  62. (define (handle-argument arg result arg-handler)
  63. ;; Treat all non-option arguments as package specs.
  64. (values (alist-cons 'remove arg result)
  65. arg-handler))
  66. (define opts
  67. (parse-command-line args %options
  68. (list %package-default-options #f)
  69. #:argument-handler handle-argument))
  70. (guix-package* opts))