Skip to content
Open
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import cowsay
import argparse

#getting avalble animal list
animals = [a for a in dir(cowsay) if not a.startswith("__") and callable(getattr(cowsay, a))]
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.

I think there is maybe an easier way to access this than filtering over everything in the package. Can you have a look at the docs and see if you find anything?


parser = argparse.ArgumentParser(
prog="cowsay program",
description="Make animals say things"
)

parser.add_argument(
"--animal",
default="cow",
choices=animals,
help=f"The animal to be saying things (choose from: {', '.join(animals)})"
)
parser.add_argument(
"message",
nargs="+",
help="message to show")

args = parser.parse_args()

text = " ".join(args.message)
animal = args.animal

getattr(cowsay, animal)(text)
1 change: 1 addition & 0 deletions implement-cowsay/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsay
Loading