diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/cli.lux | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux index d9039df13..459d6926f 100644 --- a/stdlib/source/lux/cli.lux +++ b/stdlib/source/lux/cli.lux @@ -71,24 +71,23 @@ (#;Right [inputs' arg]) _ - (#;Left "Can't extract from empty arguments.")))) + (#;Left "Can't parse empty arguments.")))) -(def: #export (parse parser option) +(def: #export (parse parser) {#;doc "Parses the next input with a parsing function."} - (All [a] (-> (-> Text (Error a)) (CLI Text) (CLI a))) + (All [a] (-> (-> Text (Error a)) (CLI a))) (lambda [inputs] - (case (option inputs) - (#;Right [inputs' input]) - (case (parser input) + (case inputs + (#;Cons arg inputs') + (case (parser arg) (#;Right value) (#;Right [inputs' value]) (#;Left parser-error) (#;Left parser-error)) - - (#;Left option-error) - (#;Left option-error) - ))) + + _ + (#;Left "Can't parse empty arguments.")))) (def: #export (option names) {#;doc "Checks that a given option (with multiple possible names) has a value."} @@ -126,8 +125,8 @@ #;Nil (#;Right [inputs []]) _ (#;Left (Text/append "Unknown parameters: " (text;join-with " " inputs)))))) -(def: #export (assert test message) - (-> Bool Text (CLI Unit)) +(def: #export (assert message test) + (-> Text Bool (CLI Unit)) (lambda [inputs] (if test (#;Right [inputs []]) |