diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 00000000..25c6c19d --- /dev/null +++ b/implement-cowsay/.gitignore @@ -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 diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 00000000..fd498bb6 --- /dev/null +++ b/implement-cowsay/cow.py @@ -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)) diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 00000000..c6b9ffd0 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay