-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.rkt
46 lines (42 loc) · 1.19 KB
/
main.rkt
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
41
42
43
44
45
#lang racket/base
(require racket/match
racket/cmdline
racket/system
raco/command-name
"src/list.rkt"
"src/clone.rkt"
"src/error.rkt")
(define listing? (make-parameter #f))
(module+ main
(define cli-args
(command-line
#:program "raco new"
#:once-any
[("-l" "--list")
"Lists all available templates to clone"
(listing? #t)]
#:args args
(with-handlers
([exn:break?
(lambda (e)
(print-error e user-abort-error)
(exit))]
[exn?
(lambda (e) (print-error e unexpected-error #t))])
(cond
[(listing?) (print-templates)]
[else
(match args
[(list)
(define cmd-name (short-program+command-name))
(define help-command
(if (string=? "raco" (substring cmd-name 0 4))
"raco new --help"
(format "racket ~a --help" cmd-name)))
(system help-command)]
[(list repo) (clone-repo repo repo)]
[(list repo dir) (clone-repo repo dir)]
;; Errors
[_ (displayln too-many-arguments-error)
(exit)])
])))))