File: argparse_ex.hy

package info (click to toggle)
hy 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,632 kB
  • sloc: python: 7,299; makefile: 38; sh: 27
file content (19 lines) | stat: -rwxr-xr-x 313 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env hy

(import sys)
(import argparse)

(setv parser (argparse.ArgumentParser))

(.add_argument parser "-i")
(.add_argument parser "-c")

(setv args (.parse_args parser))

;; using (cond) allows -i to take precedence over -c

(cond
  args.i
    (print (str args.i))
  args.c
    (print (str "got c")))