Skip to content

Commit fa8bec8

Browse files
committed
implement cowsay
1 parent e328bd5 commit fa8bec8

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

implement-cowsay/cow.py

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

implement-cowsay/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cowsay

0 commit comments

Comments
 (0)