diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..f1f69778e --- /dev/null +++ b/implement-cowsay/cow.py @@ -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() diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 000000000..c6b9ffd0e --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay