cli: fix printing of types and do not override previous errors

This commit is contained in:
2020-01-29 21:07:31 +01:00
parent 1a998a7960
commit aaf413ac04

View File

@@ -78,6 +78,12 @@ optional arguments.")
(Integer i) (Long.format s i)
(Floating f) (Double.format s f)
(Str s2) (String.format s &s2)))
(defn str [t]
(match @t
(Integer i) (str i)
(Floating f) (str f)
(Str s) (str s)))
)
(hidden Tag)
@@ -309,6 +315,7 @@ mesage is empty, `--help` was requested. If you dont want to provide a
(do
(set! res (Result.Error (fmt "Unexpected argument: %s" x)))
(break)))))
(when (Result.success? &res)
(foreach [o options]
(cond
(and @(Option.required? o)
@@ -328,7 +335,7 @@ mesage is empty, `--help` was requested. If you dont want to provide a
&(CmdMap.get &values (Option.long o))
&(join ", " &(Array.copy-map &str &opts)))))
(break))))
()))
())))
(match res
(Result.Success _) (Result.Success (CmdMap.to-map &values))
(Result.Error x) (Result.Error x))))