Skip to content

Commit 62bd86e

Browse files
Basic logic complete
1 parent 8671d12 commit 62bd86e

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

implement-cowsay/cow.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
import cowsay
22
import argparse
33

4+
animals = cowsay.char_names
5+
46
parser = argparse.ArgumentParser(
57
prog="cowsay",
68
description="Make animals say things"
79
)
810

9-
parser.add_argument("--animal", help="The animal to be saying things.")
11+
parser.add_argument("-a", "--animal", choices=animals, help="The animal to be saying things.")
1012
parser.add_argument("message", nargs="+", help="The message to say.")
1113

1214
args = parser.parse_args()
1315

14-
# cowsay.cow(" ".join(sys.argv[1:]))
16+
message = " ".join(args.message)
1517

18+
print(args)
1619

17-
animals = cowsay.char_names
20+
if args.animal:
21+
# cowsay[args.animal](message)
22+
print(cowsay.get_output_string(args.animal, message))
23+
# print('hi')
24+
else:
25+
# print(cowsay.get_output_string('cow', 'Hello World'))
26+
cowsay.cow(message) # if no animal is provided, use default
27+
28+
29+
30+
print(animals)
1831

19-
print(animals)
32+

0 commit comments

Comments
 (0)