From 91c5b839435ea999690dd67e91bf0b83c3b9a1e2 Mon Sep 17 00:00:00 2001 From: Anna Fedyna Date: Fri, 21 Mar 2025 16:08:39 +0000 Subject: [PATCH 1/3] added .venv --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e6..671215dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.venv From 59072f40d21a233676e5b78b32c4cb2c428c9d7c Mon Sep 17 00:00:00 2001 From: Anna Fedyna Date: Fri, 21 Mar 2025 16:10:17 +0000 Subject: [PATCH 2/3] added python packeges required --- 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 00000000..c6b9ffd0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +cowsay From 621f541b73fa39de4583dc27b8e9e3e6e8bcc777 Mon Sep 17 00:00:00 2001 From: Anna Fedyna Date: Fri, 21 Mar 2025 18:27:10 +0000 Subject: [PATCH 3/3] implemented cowsay command line tool --- implement-cowsay/cow.py | 22 ++++++++++++++++++++++ 1 file changed, 22 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 00000000..95ae6f8c --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,22 @@ +import argparse +import cowsay +import sys + +parser = argparse.ArgumentParser( + prog='cowsay', + description='Make animals say things') + +parser.add_argument("--animal", help="The animal to be saying things.", default='cow') +parser.add_argument("message", nargs="*", help="The message to say.") + +args = parser.parse_args() +available_animals = cowsay.char_names + +message = ' '.join(args.message) if args.message else 'Hello World !' +animal = args.animal + +if animal in available_animals: + print(cowsay.get_output_string(animal, message)) +else: + print(f"Error: '{animal}' is not a valid animal. Available animals are: {', '.join(available_animals)}") + sys.exit(1) \ No newline at end of file