From 2567a98de9c03cce137e9290f6e8f663b7149298 Mon Sep 17 00:00:00 2001 From: RahwaZeslusHaile Date: Sat, 29 Nov 2025 21:16:03 +0000 Subject: [PATCH 1/3] Ignore local virtual environment --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e6..274d0491 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.venv \ No newline at end of file From 510d4249b9e02fc4063e83ddcda49d3751463abc Mon Sep 17 00:00:00 2001 From: RahwaZeslusHaile Date: Mon, 1 Dec 2025 13:46:24 +0000 Subject: [PATCH 2/3] Add Python cowsay CLI with animal selection and validation --- implement-cowsay/cowsay_script.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 implement-cowsay/cowsay_script.py diff --git a/implement-cowsay/cowsay_script.py b/implement-cowsay/cowsay_script.py new file mode 100644 index 00000000..5d8b7ec7 --- /dev/null +++ b/implement-cowsay/cowsay_script.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import argparse +import cowsay +import sys + +def main(): + parser = argparse.ArgumentParser( + description="Make animals say things" + ) + parser.add_argument( + "message", nargs="+", help="The message to say." + ) + parser.add_argument( + "--animal", + default="cow", + help="The animal to be saying things." + ) + + args = parser.parse_args() + + text = " ".join(args.message) + animal = args.animal + + supported_animals = [ + "beavis", "cheese", "cow", "daemon", "dragon", "fox", + "ghostbusters", "kitty", "meow", "miki", "milk", "octopus", + "pig", "stegosaurus", "stimpy", "trex", "turkey", "turtle", "tux" + ] + + if animal not in supported_animals: + print(f"usage: cowsay [-h] [--animal {{{','.join(supported_animals)}}}] message [message ...]") + print(f"cowsay: error: argument --animal: invalid choice: '{animal}' (choose from {','.join(supported_animals)})") + sys.exit(1) + + output = cowsay.get_output_string(animal, text) + print(output) + +if __name__ == "__main__": + main() From 669d05e6731dd38b371e77e7191d1827a20cc232 Mon Sep 17 00:00:00 2001 From: RahwaZeslusHaile Date: Sat, 17 Jan 2026 06:19:21 +0000 Subject: [PATCH 3/3] Use cowsay.char_names instead of hard-coded animal list --- implement-cowsay/cowsay_script.py | 69 +++++++++++++++---------------- implement-cowsay/requirements.txt | 1 + 2 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 implement-cowsay/requirements.txt diff --git a/implement-cowsay/cowsay_script.py b/implement-cowsay/cowsay_script.py index 5d8b7ec7..bcf75a9b 100644 --- a/implement-cowsay/cowsay_script.py +++ b/implement-cowsay/cowsay_script.py @@ -1,39 +1,38 @@ -#!/usr/bin/env python3 import argparse import cowsay import sys -def main(): - parser = argparse.ArgumentParser( - description="Make animals say things" - ) - parser.add_argument( - "message", nargs="+", help="The message to say." - ) - parser.add_argument( - "--animal", - default="cow", - help="The animal to be saying things." - ) - - args = parser.parse_args() - - text = " ".join(args.message) - animal = args.animal - - supported_animals = [ - "beavis", "cheese", "cow", "daemon", "dragon", "fox", - "ghostbusters", "kitty", "meow", "miki", "milk", "octopus", - "pig", "stegosaurus", "stimpy", "trex", "turkey", "turtle", "tux" - ] - - if animal not in supported_animals: - print(f"usage: cowsay [-h] [--animal {{{','.join(supported_animals)}}}] message [message ...]") - print(f"cowsay: error: argument --animal: invalid choice: '{animal}' (choose from {','.join(supported_animals)})") - sys.exit(1) - - output = cowsay.get_output_string(animal, text) - print(output) - -if __name__ == "__main__": - main() +parser = argparse.ArgumentParser( + prog="cowsay", + description="Make animals say things" +) + +parser.add_argument( + "--animal", + choices=cowsay.char_names, + default="cow", + help="The animal to be saying things." +) + +parser.add_argument( + "--list-animals", + action="store_true", + help="List available animals and exit." +) + +parser.add_argument( + "message", + nargs="*", + help="The message for the animal to say." +) + +args = parser.parse_args() + +if args.list_animals: + print("\n".join(cowsay.char_names)) + sys.exit(0) + +if not args.message: + parser.error("the following arguments are required: message") + +getattr(cowsay, args.animal)(" ".join(args.message)) diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 00000000..cc557103 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay \ No newline at end of file