-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.carp
28 lines (26 loc) · 1.29 KB
/
example.carp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(load "clig.carp")
(def b (Clig.bool-flag @"bool"
(Maybe.Just @"b")
@"false"
@"Whether or not to do something"))
(def s (Clig.string-flag @"strr" (Maybe.Just @"s") @"" @"some kind of string"))
(def i (Clig.int-flag @"intr" (Maybe.Nothing) @"" @"some kind of int"))
(def p (Clig.new @"my-program" @"doesn't do anything interesting"))
(defn main []
(do (Clig.add-flags &p [@&b @&s @&i])
(match (Clig.parse &p false)
(Result.Error err)
(do (IO.println &(String.concat &[@"last error encountered: " (str err)]))
(IO.println &(String.concat &[@"all errors: "
(Clig.get-errors-string &p)])))
(Result.Success _)
(do (IO.println "success")
(IO.println &(str (CligProgram.args &p)))
(IO.println &(str (CligProgram.name &p)))
(IO.println &(str (CligProgram.flags &p)))
(IO.println (CligFlag.value &(unsafe-from (Clig.get-flag &p "bool"))))
(IO.println &(str &(Clig.get-flag &p "carp")))
(IO.println &(Clig.get &p "bool"))
(IO.println &(Clig.get &p "carp"))
(IO.println &(str (CligProgram.errors &p)))
(IO.println &(Clig.usage &p))))))