Skip to content

Commit b5d1672

Browse files
cowsay done
1 parent 4350f48 commit b5d1672

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

implement-cowsay/cow.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import cowsay
2+
import argparse
3+
4+
#getting avalble animal list
5+
animals = [a for a in dir(cowsay) if not a.startswith("__") and callable(getattr(cowsay, a))]
6+
7+
parser = argparse.ArgumentParser(
8+
prog="cowsay program",
9+
description="Make animals say things"
10+
)
11+
12+
parser.add_argument(
13+
"--animal",
14+
default="cow",
15+
choices=animals,
16+
help=f"The animal to be saying things (choose from: {', '.join(animals)})"
17+
)
18+
parser.add_argument(
19+
"message",
20+
nargs="+",
21+
help="message to show")
22+
23+
args = parser.parse_args()
24+
25+
text = " ".join(args.message)
26+
animal = args.animal
27+
28+
getattr(cowsay, animal)(text)

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)