gnu: tor: Update to 0.4.5.9 [security fixes].
[jackhill/guix/guix.git] / guix / scripts / git.scm
CommitLineData
a9871278
LC
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
19(define-module (guix scripts git)
20 #:use-module (ice-9 match)
21 #:use-module (guix ui)
3794ce93 22 #:use-module (guix scripts)
a9871278
LC
23 #:export (guix-git))
24
25(define (show-help)
26 (display (G_ "Usage: guix git COMMAND ARGS...
27Operate on Git repositories.\n"))
28 (newline)
29 (display (G_ "The valid values for ACTION are:\n"))
30 (newline)
31 (display (G_ "\
32 authenticate verify commit signatures and authorizations\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 (show-bug-report-information))
40
41(define %sub-commands '("authenticate"))
42
43(define (resolve-sub-command name)
44 (let ((module (resolve-interface
45 `(guix scripts git ,(string->symbol name))))
46 (proc (string->symbol (string-append "guix-git-" name))))
47 (module-ref module proc)))
48
3794ce93
LC
49(define-command (guix-git . args)
50 (category plumbing)
51 (synopsis "operate on Git repositories")
52
a9871278
LC
53 (with-error-handling
54 (match args
55 (()
56 (format (current-error-port)
57 (G_ "guix git: missing sub-command~%")))
58 ((or ("-h") ("--help"))
59 (show-help)
60 (exit 0))
61 ((or ("-V") ("--version"))
62 (show-version-and-exit "guix git"))
63 ((sub-command args ...)
64 (if (member sub-command %sub-commands)
65 (apply (resolve-sub-command sub-command) args)
66 (format (current-error-port)
67 (G_ "guix git: invalid sub-command~%")))))))