aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/cli.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/cli.lux')
-rw-r--r--stdlib/source/lux/tool/compiler/cli.lux41
1 files changed, 41 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/cli.lux b/stdlib/source/lux/tool/compiler/cli.lux
new file mode 100644
index 000000000..7e92b2c34
--- /dev/null
+++ b/stdlib/source/lux/tool/compiler/cli.lux
@@ -0,0 +1,41 @@
+(.module:
+ [lux #*
+ [control
+ ["p" parser]]
+ ["." cli (#+ CLI)]
+ [world
+ [file (#+ File)]]]
+ [///
+ [importer (#+ Source)]])
+
+(type: #export Configuration
+ {#sources (List Source)
+ #target File
+ #module Text})
+
+(type: #export Service
+ (#Compilation Configuration)
+ (#Interpretation Configuration))
+
+(do-template [<name> <short> <long>]
+ [(def: #export <name>
+ (CLI Text)
+ (cli.parameter [<short> <long>]))]
+
+ [source "-s" "--source"]
+ [target "-t" "--target"]
+ [module "-m" "--module"]
+ )
+
+(def: #export configuration
+ (CLI Configuration)
+ ($_ p.and
+ (p.some ..source)
+ ..target
+ ..module))
+
+(def: #export service
+ (CLI Service)
+ ($_ p.or
+ (p.after (cli.this "build") ..configuration)
+ (p.after (cli.this "repl") ..configuration)))