diff options
author | Eduardo Julian | 2018-08-11 10:59:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-08-11 10:59:38 -0400 |
commit | 0fe039a41571328a29b7a620643fc5e30e32b9a3 (patch) | |
tree | 0593a3ca8ff0e23f3d73647e9015ab01f57f77e6 | |
parent | 13265c95fcacf9952bc61ebece64078d8b6124ec (diff) |
Moved CLI machinery to stdlib.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/program.lux | 52 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/cli.lux | 53 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default.lux | 7 |
3 files changed, 61 insertions, 51 deletions
diff --git a/new-luxc/source/program.lux b/new-luxc/source/program.lux index 7cb10b457..4e0925717 100644 --- a/new-luxc/source/program.lux +++ b/new-luxc/source/program.lux @@ -13,11 +13,12 @@ ["." io (#+ IO Process io)] [time ["." instant]] - ["." cli (#+ CLI program:)] + [cli (#+ program:)] [world ["." file (#+ File)]] [compiler - ["." default (#+ Configuration Platform)]]] + ["." cli] + ["." default (#+ Platform)]]] [luxc ## ["." repl] [lang @@ -27,47 +28,6 @@ ["." runtime] ["." expression]]]]]) -(type: Build - [Configuration Text]) - -(type: REPL - Configuration) - -(do-template [<name> <short> <long>] - [(def: <name> - (CLI Text) - (cli.parameter [<short> <long>]))] - - [source "-s" "--source"] - [target "-t" "--target"] - [program "-p" "--program"] - ) - -(def: configuration - (CLI Configuration) - ($_ p.and - (p.some ..source) - ..target)) - -(def: build - (CLI Build) - ($_ p.and - configuration - ..program)) - -(def: repl - (CLI REPL) - ..configuration) - -(type: Service - (#Build Build) - (#REPL REPL)) - -(def: service - (CLI Service) - (p.or (p.after (cli.this "build") build) - (p.after (cli.this "repl") repl))) - (def: (or-crash! failure-describer action) (All [a] (-> Text (Task a) (Promise a))) @@ -103,18 +63,18 @@ #default.runtime runtime.translate #default.file-system file.JVM@System}))) -(program: [{service ..service}] +(program: [{service cli.service}] (do io.Monad<IO> [platform ..jvm-platform] (wrap (: (Promise Any) (case service - (#Build [configuration program]) + (#cli.Build [configuration program]) (<| (or-crash! "Compilation failed:") promise.future ..timed (default.compile platform configuration program)) - (#REPL configuration) + (#cli.REPL configuration) (undefined) ## (<| (or-crash! "REPL failed:") ## (repl.run sources target)) diff --git a/stdlib/source/lux/compiler/cli.lux b/stdlib/source/lux/compiler/cli.lux new file mode 100644 index 000000000..a73eb5a15 --- /dev/null +++ b/stdlib/source/lux/compiler/cli.lux @@ -0,0 +1,53 @@ +(.module: + [lux #* + [control + ["p" parser]] + ["." cli (#+ CLI)] + [world + [file (#+ File)]]]) + +(type: #export Configuration + {#sources (List File) + #target File}) + +(type: #export Build + [Configuration Text]) + +(type: #export REPL + Configuration) + +(type: #export Service + (#Build Build) + (#REPL REPL)) + +(do-template [<name> <short> <long>] + [(def: #export <name> + (CLI Text) + (cli.parameter [<short> <long>]))] + + [source "-s" "--source"] + [target "-t" "--target"] + [program "-p" "--program"] + ) + +(def: #export configuration + (CLI Configuration) + ($_ p.and + (p.some ..source) + ..target)) + +(def: #export build + (CLI Build) + ($_ p.and + configuration + ..program)) + +(def: #export repl + (CLI REPL) + ..configuration) + +(def: #export service + (CLI Service) + ($_ p.or + (p.after (cli.this "build") ..build) + (p.after (cli.this "repl") ..repl))) diff --git a/stdlib/source/lux/compiler/default.lux b/stdlib/source/lux/compiler/default.lux index f06a235de..cb93fdba4 100644 --- a/stdlib/source/lux/compiler/default.lux +++ b/stdlib/source/lux/compiler/default.lux @@ -16,6 +16,7 @@ [world ["." file (#+ File)]]] [// + ["." cli (#+ Configuration)] [meta [io ["." context]]]] @@ -64,10 +65,6 @@ ## ## (format module-name "/" cache.descriptor-name) ## ## (encoding.to-utf8 (%code (cache/description.write file-name module)))))) -(type: #export Configuration - {#sources (List File) - #target File}) - (type: #export (Platform fs anchor expression statement) {#host (Host expression statement) #phase (translation.Phase anchor expression statement) @@ -126,7 +123,7 @@ (-> <Platform> Configuration Text <Compiler> (fs <Compiler>))) (do (:: (get@ #file-system platform) &monad) [source (context.read (get@ #file-system platform) - (get@ #sources configuration) + (get@ #cli.sources configuration) module-name) ## _ (&io.prepare-module target-dir module-name) ## _ (write-module target-dir file-name module-name module artifacts) |