From f9617e9baa011d31b8718b4c802c646f8412155f Mon Sep 17 00:00:00 2001 From: Nataliia Volkova Date: Sun, 30 Nov 2025 16:50:04 +0000 Subject: [PATCH 1/3] implamant cowsay func as a shell command written python --- implement-cowsay/animalsay.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 implement-cowsay/animalsay.py diff --git a/implement-cowsay/animalsay.py b/implement-cowsay/animalsay.py new file mode 100644 index 000000000..98526f3c7 --- /dev/null +++ b/implement-cowsay/animalsay.py @@ -0,0 +1,22 @@ +import cowsay +import argparse + +# cowsay.cow(" ".join(sys.argv[1:])) + +# cowsay.turtle(" ".join(sys.argv[1:])) + +# cowsay.fish(" ".join(sys.argv[1:])) + +parser = argparse.ArgumentParser( + prog = "cowsay shell command", + description = "cowsay shell command on python Make animals say things" +) +animals = ["beavis","cheese","cow","daemon","dragon","fox","ghostbusters","kitty","meow","miki","milk","octopus","pig","stegosaurus","stimpy","trex","turkey","turtle","tux"] +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() + +cowsay_function = getattr(cowsay, args.animal) +cowsay_function(" ".join(args.message)) + From 2d5383ad65061b19062ce38df4e83e2864fb9521 Mon Sep 17 00:00:00 2001 From: Nataliia Volkova Date: Sun, 30 Nov 2025 16:58:51 +0000 Subject: [PATCH 2/3] dependencies for cowsay python --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..c6b9ffd0e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +cowsay From 3942ce7fe781730a779534c959a627620d85c03d Mon Sep 17 00:00:00 2001 From: Nataliia Volkova Date: Tue, 23 Dec 2025 18:08:19 +0000 Subject: [PATCH 3/3] an inbuild function to get a list of animals in the library cowsay --- implement-cowsay/animalsay.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/implement-cowsay/animalsay.py b/implement-cowsay/animalsay.py index 98526f3c7..09087a269 100644 --- a/implement-cowsay/animalsay.py +++ b/implement-cowsay/animalsay.py @@ -1,22 +1,17 @@ import cowsay import argparse -# cowsay.cow(" ".join(sys.argv[1:])) - -# cowsay.turtle(" ".join(sys.argv[1:])) - -# cowsay.fish(" ".join(sys.argv[1:])) - parser = argparse.ArgumentParser( prog = "cowsay shell command", description = "cowsay shell command on python Make animals say things" ) -animals = ["beavis","cheese","cow","daemon","dragon","fox","ghostbusters","kitty","meow","miki","milk","octopus","pig","stegosaurus","stimpy","trex","turkey","turtle","tux"] +# animals = ["beavis","cheese","cow","daemon","dragon","fox","ghostbusters","kitty","meow","miki","milk","octopus","pig","stegosaurus","stimpy","trex","turkey","turtle","tux"] +animals = cowsay.char_names 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() -cowsay_function = getattr(cowsay, args.animal) +cowsay_function = cowsay.char_funcs[args.animal] cowsay_function(" ".join(args.message))