aboutsummaryrefslogtreecommitdiff
path: root/lux-bootstrapper/src/lux.clj
blob: 783a25a640a955c7855cc16ab73993db4d4a50bd (plain)
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
(ns lux
  (:gen-class)
  (:require [lux.base :as & :refer [|let |do return return* |case]]
            [lux.compiler :as &compiler]
            [lux.repl :as &repl]
            [clojure.string :as string]
            :reload-all)
  (:import (java.io File)))

(def unit-separator
  (str (char 31)))

(defn- separate-paths
  "(-> Text (List Text))"
  [paths]
  (-> paths
      (string/replace unit-separator "\n")
      string/split-lines
      rest
      &/->list))

(defn -main [& args]
  (|case (&/->list args)
    (&/$Item "release" (&/$Item program-module (&/$Item dependencies (&/$Item source-dirs (&/$Item target-dir (&/$End))))))
    (&compiler/compile-program &/$Build program-module
                               (separate-paths dependencies)
                               (separate-paths source-dirs)
                               target-dir)

    (&/$Item "repl" (&/$Item dependencies (&/$Item source-dirs (&/$Item target-dir (&/$End)))))
    (&repl/repl (separate-paths dependencies)
                (separate-paths source-dirs)
                target-dir)

    _
    (println "Cannot understand command.")))