From c6b64e5ccabb1b15d6e293ad9734f1a73dd5ea63 Mon Sep 17 00:00:00 2001 From: aiah ibrahim Date: Tue, 5 Aug 2025 16:16:59 +0100 Subject: [PATCH] cowsay --- implement-cowsay/cow.py | 31 +++++++++++++++++++++++++++++++ implement-cowsay/requirements.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 implement-cowsay/cow.py create mode 100644 implement-cowsay/requirements.txt diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 00000000..a1e6ad31 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +import cowsay +import argparse + +def main(): + + animals = cowsay.char_names + + # Set up command-line argument parsing + parser = argparse.ArgumentParser( prog="cowsay", description="Make animals say things") + parser.add_argument( + "--animal", + choices=animals, + default="cow", + help="The animal to be saying things." + ) + parser.add_argument( + "message", + nargs="+", + help="The message to say." + ) + + args = parser.parse_args() + + message = " ".join(args.message) + + say_function = getattr(cowsay, args.animal) + say_function(message) + +if __name__ == "__main__": + main() 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