cli: fix printing of types and do not override previous errors
This commit is contained in:
9
cli.carp
9
cli.carp
@@ -78,6 +78,12 @@ optional arguments.")
|
|||||||
(Integer i) (Long.format s i)
|
(Integer i) (Long.format s i)
|
||||||
(Floating f) (Double.format s f)
|
(Floating f) (Double.format s f)
|
||||||
(Str s2) (String.format s &s2)))
|
(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)
|
(hidden Tag)
|
||||||
@@ -309,6 +315,7 @@ mesage is empty, `--help` was requested. If you don’t want to provide a
|
|||||||
(do
|
(do
|
||||||
(set! res (Result.Error (fmt "Unexpected argument: %s" x)))
|
(set! res (Result.Error (fmt "Unexpected argument: %s" x)))
|
||||||
(break)))))
|
(break)))))
|
||||||
|
(when (Result.success? &res)
|
||||||
(foreach [o options]
|
(foreach [o options]
|
||||||
(cond
|
(cond
|
||||||
(and @(Option.required? o)
|
(and @(Option.required? o)
|
||||||
@@ -328,7 +335,7 @@ mesage is empty, `--help` was requested. If you don’t want to provide a
|
|||||||
&(CmdMap.get &values (Option.long o))
|
&(CmdMap.get &values (Option.long o))
|
||||||
&(join ", " &(Array.copy-map &str &opts)))))
|
&(join ", " &(Array.copy-map &str &opts)))))
|
||||||
(break))))
|
(break))))
|
||||||
()))
|
())))
|
||||||
(match res
|
(match res
|
||||||
(Result.Success _) (Result.Success (CmdMap.to-map &values))
|
(Result.Success _) (Result.Success (CmdMap.to-map &values))
|
||||||
(Result.Error x) (Result.Error x))))
|
(Result.Error x) (Result.Error x))))
|
||||||
|
Reference in New Issue
Block a user