diff options
author | Eduardo Julian | 2018-05-08 21:08:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-08 21:08:43 -0400 |
commit | ca9541c0c10d4e6aa94055ecfb47301ed7292828 (patch) | |
tree | fa235422c055908c6299bb34c17d603959a0afb0 /stdlib | |
parent | 10655fdd7bc6c88a417ec33237ae992d79cf3dd6 (diff) |
- Improved the way "lux program" is analysed and compiled.
- Improved the syntax for "program:" arguments.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/cli.lux | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index 466895876..72a22a267 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -97,10 +97,10 @@ (def: program-args^ (Syntax Program-Args) (p.alt s.local-symbol - (s.form (p.some (p.either (do p.Monad<Parser> - [name s.local-symbol] - (wrap [(code.symbol ["" name]) (` any)])) - (s.tuple (p.seq s.any s.any))))))) + (s.tuple (p.some (p.either (do p.Monad<Parser> + [name s.local-symbol] + (wrap [(code.symbol ["" name]) (` any)])) + (s.record (p.seq s.any s.any))))))) (syntax: #export (program: {args program-args^} @@ -113,39 +113,42 @@ bar (do-something all-args)] (wrap []))) - (program: (name) + (program: [name] (io (log! (text/compose "Hello, " name)))) - (program: ([config config^]) + (program: [{config config^}] (do Monad<IO> [data (init-program config)] (do-something data))))} - (case args - (#Raw args) - (wrap (list (` ("lux program" (~ (code.symbol ["" args])) - ((~! do) (~! io.Monad<IO>) - [] - (~ body)))))) - - (#Parsed args) - (with-gensyms [g!args g!_ g!output g!message] - (wrap (list (` ("lux program" (~ g!args) - (case ((: (~! (..CLI (io.IO .Top))) - ((~! do) (~! p.Monad<Parser>) - [(~+ (|> args - (list/map (function (_ [binding parser]) - (list binding parser))) - list/join)) - (~ g!_) ..end] - ((~' wrap) ((~! do) (~! io.Monad<IO>) - [] - (~ body))))) - (~ g!args)) - (#E.Success [(~ g!_) (~ g!output)]) - (~ g!output) - - (#E.Error (~ g!message)) - (error! (~ g!message)) - ))) - ))) - )) + (with-gensyms [g!program] + (case args + (#Raw args) + (wrap (list (` ("lux program" + (.function ((~ g!program) (~ (code.symbol ["" args]))) + ((~! do) (~! io.Monad<IO>) + [] + (~ body))))))) + + (#Parsed args) + (with-gensyms [g!args g!_ g!output g!message] + (wrap (list (` ("lux program" + (.function ((~ g!program) (~ g!args)) + (case ((: (~! (..CLI (io.IO .Top))) + ((~! do) (~! p.Monad<Parser>) + [(~+ (|> args + (list/map (function (_ [binding parser]) + (list binding parser))) + list/join)) + (~ g!_) ..end] + ((~' wrap) ((~! do) (~! io.Monad<IO>) + [] + (~ body))))) + (~ g!args)) + (#E.Success [(~ g!_) (~ g!output)]) + (~ g!output) + + (#E.Error (~ g!message)) + (error! (~ g!message)) + )))) + ))) + ))) |