From 55e411f34d81d8deb0b7d0e25c987dbe16035354 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 2 Dec 2016 09:59:01 -0400 Subject: - Updated lux/cli tests. --- stdlib/source/lux/cli.lux | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'stdlib/source') 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 []]) -- cgit v1.2.3