From b10c619dd75d40fa7120c11af65f734be29c1e6a Mon Sep 17 00:00:00 2001 From: Fithi Teklom Date: Thu, 30 Jul 2026 22:07:14 +0100 Subject: [PATCH] Complete implementing cowsay exercise --- implement-cowsay/.gitignore | 1 + implement-cowsay/cow.py | 30 ++++++++++++++++++++++++++++++ implement-cowsay/requirements.txt | 1 + 3 files changed, 32 insertions(+) create mode 100644 implement-cowsay/.gitignore create mode 100644 implement-cowsay/cow.py create mode 100644 implement-cowsay/requirements.txt 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..a07142cbd --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,30 @@ +import cowsay +import argparse + +parser = argparse.ArgumentParser( + prog="cowsay", + description="Make animals say things", +) + +parser.add_argument( + "message", + nargs="+", + help="The message to say.", +) + +parser.add_argument( + "--animal", + choices = cowsay.char_names, + default="cow", + help="The animal to be saying things.", +) + +args = parser.parse_args() +message = " ".join(args.message) + +animal_function = getattr(cowsay, args.animal) + +animal_function(message) + +# print(message) +# print(args.animal) \ No newline at end of file diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 000000000..cc5571034 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay \ No newline at end of file