Skip to content

Commit 8aed1b1

Browse files
authored
Merge pull request #280 from brendanhowell/master
Add example for spork/argparse/argparse
2 parents c8b5374 + 1198f4a commit 8aed1b1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(import spork)
2+
3+
(def argparse-params
4+
["An example CLI tool."
5+
"my-flag" {:kind :flag
6+
:short "f"
7+
:help "set my-flag"}
8+
"my-opt" {:kind :option
9+
:short "o"
10+
:help "Value for option"
11+
:default "DEFAULT VALUE"}
12+
"my-req" {:kind :option
13+
:short "r"
14+
:required true}])
15+
16+
(def cli-args (spork/argparse/argparse ;argparse-params))
17+
18+
(unless cli-args
19+
(os/exit 1))
20+
21+
(print "flag: " (get cli-args "my-flag"))
22+
(print "my-opt: " (get cli-args "my-opt"))
23+
(print "my-req: " (get cli-args "my-req"))

0 commit comments

Comments
 (0)