diff --git a/.gitignore b/.gitignore index 3c3629e64..671215ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.venv diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..99ba593dc --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,22 @@ +import cowsay +import argparse + +# 1. Fetch the animals from the library +list_of_animals = cowsay.char_names + +# 2. Setup the Parser, I'm building a program cowsay that to do(description). +parse = argparse.ArgumentParser(prog='cowsay', description='make animals say things') +parse.add_argument('message', nargs='+', help='The message to say') + +parse.add_argument('--animal', choices=list_of_animals, default='cow', help='The animal to use') + +args = parse.parse_args() + +# Combining the words into a single string +message_text = " ".join(args.message) + +# we call the draw_function and we use getattr because args.animal is a string, and we need a function instead. +draw_function = getattr(cowsay, args.animal) + +# 4. call and execute. +draw_function(message_text) diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 000000000..9e0634373 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay==6.1