diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 000000000..a230a78ae --- /dev/null +++ b/implement-cowsay/.gitignore @@ -0,0 +1,2 @@ +.venv/ +__pycache__/ diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..9f0c92fe8 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,21 @@ +import argparse +import cowsay + +parser = argparse.ArgumentParser(prog="cow.py", + description="Print a message using a cowsay animal") + +parser.add_argument("message") +parser.add_argument("-a", + "--animal", + default="cow", + help="Animal to use for the speech bubble.") + +args = parser.parse_args() + +animal_names = cowsay.char_names + +if args.animal not in animal_names: + parser.error("The specified animal is not found in the cowsay animal list.") + +animal_function = getattr(cowsay, args.animal) +animal_function(args.message) 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