From ccd44ffcde5673ff0cf4a3af8f3fee7fae8ec621 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 21 Apr 2026 23:14:49 +0200 Subject: [PATCH] cowsay python --- implement-cowsay/cow.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 implement-cowsay/cow.py diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..5da23c518 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,32 @@ +import argparse +import cowsay +import sys + +def main(): + available_animals = sorted(cowsay.char_names) + + parser = argparse.ArgumentParser( + prog = "cowsay", + description = "Make animals say things" + ) + + parser.add_argument( + "--animal", + choices=available_animals, + default="cow", + help="The animal to be saying things." + ) + parser.add_argument( + "message", + nargs="+", + help="The message to say." + ) + + args = parser.parse_args() + + full_message = " ".join(args.message) + + print(cowsay.get_output_string(args.animal, full_message)) + +if __name__ == "__main__": + main()