git.scm 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 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 git)
  19. #:use-module (ice-9 match)
  20. #:use-module (guix ui)
  21. #:use-module (guix scripts)
  22. #:export (guix-git))
  23. (define (show-help)
  24. (display (G_ "Usage: guix git COMMAND ARGS...
  25. Operate on Git repositories.\n"))
  26. (newline)
  27. (display (G_ "The valid values for ACTION are:\n"))
  28. (newline)
  29. (display (G_ "\
  30. authenticate verify commit signatures and authorizations\n"))
  31. (newline)
  32. (display (G_ "
  33. -h, --help display this help and exit"))
  34. (display (G_ "
  35. -V, --version display version information and exit"))
  36. (newline)
  37. (show-bug-report-information))
  38. (define %sub-commands '("authenticate"))
  39. (define (resolve-sub-command name)
  40. (let ((module (resolve-interface
  41. `(guix scripts git ,(string->symbol name))))
  42. (proc (string->symbol (string-append "guix-git-" name))))
  43. (module-ref module proc)))
  44. (define-command (guix-git . args)
  45. (category plumbing)
  46. (synopsis "operate on Git repositories")
  47. (with-error-handling
  48. (match args
  49. (()
  50. (format (current-error-port)
  51. (G_ "guix git: missing sub-command~%")))
  52. ((or ("-h") ("--help"))
  53. (show-help)
  54. (exit 0))
  55. ((or ("-V") ("--version"))
  56. (show-version-and-exit "guix git"))
  57. ((sub-command args ...)
  58. (if (member sub-command %sub-commands)
  59. (apply (resolve-sub-command sub-command) args)
  60. (format (current-error-port)
  61. (G_ "guix git: invalid sub-command~%")))))))