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
1 change: 1 addition & 0 deletions implement-cowsay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv/
17 changes: 17 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import argparse
import cowsay


parser = argparse.ArgumentParser(description="implement Cowsay command")
parser.add_argument("text", help="Text to be displayed")
parser.add_argument("--animal", help="Animal to say the text", default="cow")

Choose a reason for hiding this comment

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

Can you get the help to show the list of possible animals?

args = parser.parse_args()

animals = cowsay.char_names
animal = args.animal.lower()
if animal not in animals:
print(f"Invalid animal. Supported animals are: {', '.join(animals)}")
exit(1)
cowsay.char_funcs[animal](args.text)

Choose a reason for hiding this comment

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

What happens if I give my arguments as plain text, without quotes?