-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.rkt
More file actions
42 lines (37 loc) · 1.12 KB
/
cli.rkt
File metadata and controls
42 lines (37 loc) · 1.12 KB
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
#lang racket/base
(require racket/cmdline
racket/file
racket/path
"main.rkt")
(provide main)
(define (run-path path)
(define full-path
(simplify-path (path->complete-path path)))
(define base-dir
(or (path-only full-path)
(current-directory)))
(parameterize ([current-directory base-dir])
(run-program (parse-program (file->string full-path)))))
(define (main [argv (vector->list (current-command-line-arguments))])
(define trace? #f)
(define source-path #f)
(with-handlers ([exn:fail?
(lambda (e)
(if trace?
(raise e)
(begin
(displayln (exn-message e) (current-error-port))
1)))])
(parameterize ([current-command-line-arguments (list->vector argv)])
(command-line
#:program "lolcode"
#:once-each
[("--trace")
"Print full Racket stack trace on failures."
(set! trace? #t)]
#:args (file)
(set! source-path file)))
(run-path source-path)
0))
(module+ main
(exit (main)))