Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import argparse
from email import message
import cowsay

def main():
#Get the list of animals from cowsay library
animals = sorted(cowsay.char_names)
parser = argparse.ArgumentParser(
prog="cowsay",
description= "Make animal say things"
)

parser.add_argument(
"--animal",
choices=animals,
default="cow",
help="The animal to say the message."
)
parser.add_argument(
"message",
nargs="+",
help="The message to be said by the animal."
)

args = parser.parse_args()
# Join message list into a single string
text = " ".join(args.message)
# Default animal is "cow" if not specified
print(cowsay.get_output_string(args.animal, text))

if __name__ == "__main__":
main()
Loading