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 #helps you collect the words typed in command line

def main():
# Set up command-line parser
parser = argparse.ArgumentParser(
prog="cowsay",
description="Make animals say things"
)
parser.add_argument(
"--animal",
choices=cowsay.char_names, # fetch supported animals directly from cowsay
default="cow",
help="The animal chosen to be saying things"
)
parser.add_argument(
"message",
nargs="+", # accept one or more words as message
help="The message to say"
)
args = parser.parse_args()

# Dynamically call the correct cowsay function
say = getattr(cowsay, args.animal)
say(" ".join(args.message))

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions implement-cowsay/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsay