10000 Fix regressions introduced by #97 · repos-javascript-compilers/wisp@59cdcc2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59cdcc2

Browse files
committed
Fix regressions introduced by wisp-lang#97
1 parent 1c1b817 commit 59cdcc2

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/wisp.wisp

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[path :refer [basename dirname join resolve]]
66
[module :refer [Module]]
77
[commander]
8+
[wisp.package :refer [version]]
89

910
[wisp.string :refer [split join upper-case replace]]
1011
[wisp.sequence :refer [first second last count reduce rest
@@ -64,22 +65,34 @@
6465
(first operations)
6566
(rest operations)))
6667

68+
(defn parse-params
69+
[params]
70+
(let [options (-> commander
71+
(.version version)
72+
(.usage "[options] <file ...>")
73+
(.option "-r, --run"
74+
"compile and execute the file (same as wisp path/to/file.wisp)")
75+
(.option "-c, --compile"
76+
"compile given file and prints to stdout")
77+
(.option "-i, --interactive"
78+
"run an interactive wisp REPL (same as wisp with no params)")
79+
(.option "--print <format>"
80+
"use custom print output `expansion`,`forms`, `ast`, `js-ast` or (default) `code`"
81+
str
82+
"code")
83+
(.option "--no-map"
84+
"disable source map generation")
85+
(.parse params))]
86+
(conj {:no-map (not (:map options))}
87+
options)))
88+
6789
(defn main
6890
[]
69-
(let [options commander]
70-
(-> options
71-
(.usage "[options] <file ...>")
72-
(.option "-r, --run" "Compile and execute the file")
73-
(.option "-c, --compile" "Compile to JavaScript and save as .js files")
74-
(.option "-i, --interactive" "Run an interactive wisp REPL")
75-
(.option "--debug, --print <type>" "Print debug information. Possible values are `expansion`,`forms`, `ast` and `js-ast`")
76-
(.option "--no-map" "Disable source map generation")
77-
(.parse process.argv))
78-
(set! (aget options "no-map") (not (aget options "map"))) ;; commander auto translates to camelCase
79-
(cond options.run (run (get options.args 0))
91+
(let [options (parse-params process.argv)
92+
path (aget options.args 0)]
93+
(cond options.run (run path)
8094
(not process.stdin.isTTY) (compile-stdin options)
8195
options.interactive (start-repl)
82-
options.compile (compile-file (get options.args 0) options)
83-
options.args (run options.args)
84-
:else (start-repl)
85-
)))
96+
options.compile (compile-file path options)
97+
path (run path)
98+
:else (start-repl))))

0 commit comments

Comments
 (0)
0