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
14 changes: 14 additions & 0 deletions implement-cowsay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python cache
__pycache__/
*.pyc
*.pyo

# Virtual environments
.venv/
venv/
env/
.env/

# macOS Finder file (ignore if on Mac)
.DS_Store
name
30 changes: 30 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import argparse
import cowsay

parser = argparse.ArgumentParser(
prog="cowsay",
description="program to make animal say things"
)

# to fetch animals names
animals = cowsay.char_names

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

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

args = parser.parse_args()

# get the correct animal function by name
animal_func = getattr(cowsay, args.animal)

animal_func(" ".join(args.message))
1 change: 1 addition & 0 deletions implement-cowsay/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsay