-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lisp
40 lines (37 loc) · 1.54 KB
/
main.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
;; Copyright © 2022–2024 Hraban Luyat
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as published
;; by the Free Software Foundation, version 3 of the License.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(defpackage #:git-hly
(:nicknames #:git-hly/main)
(:use #:arrow-macros #:cl #:git-hly/src/cmd)
(:import-from #:uiop)
(:import-from #:trivia)
(:import-from #:trivia.ppcre)
(:import-from #:git-hly/src/cmds/children)
(:import-from #:git-hly/src/cmds/graft)
(:import-from #:git-hly/src/cmds/pullfetch)
(:import-from #:git-hly/src/cmds/split)
(:export #:main))
(in-package #:git-hly/main)
(defun main (&optional argv)
"Argv follows buildapp convention: single list containing full argv"
;; This works because argv is never NIL
(let* ((argv (or argv (uiop:raw-command-line-arguments))))
(trivia:match (-> argv first file-namestring)
("git-hly"
(cmd (cadr argv) (cddr argv)))
(;; If the command name starts with “git-”, strip that prefix
(trivia.ppcre:ppcre "^git-(.*)" name)
(cmd name (rest argv)))
(name
(cmd name (rest argv))))))