-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathcow.py
More file actions
28 lines (22 loc) · 609 Bytes
/
cow.py
File metadata and controls
28 lines (22 loc) · 609 Bytes
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
import cowsay
import argparse
#getting avalble animal list
animals = [a for a in dir(cowsay) if not a.startswith("__") and callable(getattr(cowsay, a))]
parser = argparse.ArgumentParser(
prog="cowsay program",
description="Make animals say things"
)
parser.add_argument(
"--animal",
default="cow",
choices=animals,
help=f"The animal to be saying things (choose from: {', '.join(animals)})"
)
parser.add_argument(
"message",
nargs="+",
help="message to show")
args = parser.parse_args()
text = " ".join(args.message)
animal = args.animal
getattr(cowsay, animal)(text)