Skip to content

Commit 58619f1

Browse files
committed
implement cowsay task
1 parent 3f26722 commit 58619f1

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

implement-cowsay/cow.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import argparse
2+
import cowsay
3+
4+
5+
parser = argparse.ArgumentParser(description="Make animals say things")
6+
7+
# Get supported animals from cowsay library
8+
animals = list(cowsay.char_funcs.keys())
9+
10+
parser.add_argument(
11+
"message",
12+
nargs="+",
13+
help="The message to say."
14+
)
15+
16+
parser.add_argument(
17+
"--animal",
18+
choices=animals,
19+
default="cow",
20+
help="The animal to be saying things."
21+
)
22+
23+
args = parser.parse_args()
24+
25+
message = " ".join(args.message)
26+
27+
# Call the selected animal function from cowsay
28+
animal = getattr(cowsay, args.animal)
29+
30+
animal(message)

0 commit comments

Comments
 (0)