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
29 changes: 29 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import cowsay
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something extra you need to commit in order to be able to use this import?

import argparse

# get valid animals dynamically from the library
animals = [
name for name in dir(cowsay)
if name.islower() and callable(getattr(cowsay, name))
]

parser = argparse.ArgumentParser(description="Make animals say things")

parser.add_argument(
"message",
nargs="+",
help="The message to say."
)

parser.add_argument(
"--animal",
choices=animals,
default="cow",
help="The animal to be saying things."
)

args = parser.parse_args()

message = " ".join(args.message)

getattr(cowsay, args.animal)(message)
Loading