diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 000000000..21d0b898f --- /dev/null +++ b/implement-cowsay/.gitignore @@ -0,0 +1 @@ +.venv/ diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..236f4f3ce --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,18 @@ +import cowsay +import sys +import argparse + +parser = argparse.ArgumentParser( + prog="cowsay", + description="Make animals say things", +) + +parser.add_argument("--animal", choices=cowsay.char_names, help="The animal to be saying things.", default="cow") +parser.add_argument("message", nargs="*", help="The message to say.") + +args = parser.parse_args() + +if args.animal not in cowsay.char_names: + sys.exit(f"Unknown animal: {args.animal!r}. Choose from: {', '.join(cowsay.char_names)}") + +cowsay.char_funcs[args.animal](" ".join(args.message)) \ No newline at end of file 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