From 0bd44cc6b1201c4c37364e0d56622b94d2fe3830 Mon Sep 17 00:00:00 2001 From: Ammad Date: Sat, 13 Jun 2026 21:47:08 +0100 Subject: [PATCH 1/7] Create .gitignore and cow.py file and install the dependencies. --- implement-cowsay/.gitignore | 2 ++ implement-cowsay/cow.py | 2 ++ implement-cowsay/requirements.txt | 1 + 3 files changed, 5 insertions(+) create mode 100644 implement-cowsay/.gitignore create mode 100644 implement-cowsay/cow.py create mode 100644 implement-cowsay/requirements.txt diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 000000000..a230a78ae --- /dev/null +++ b/implement-cowsay/.gitignore @@ -0,0 +1,2 @@ +.venv/ +__pycache__/ diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..f880233ab --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,2 @@ +import cowsay +import sys diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 000000000..c6b9ffd0e --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay From abb66cf3ba77d2d99bfbf5a6c7786ee70cad4705 Mon Sep 17 00:00:00 2001 From: Ammad Date: Sun, 14 Jun 2026 16:25:30 +0100 Subject: [PATCH 2/7] Implement configurable cowsay animal. --- implement-cowsay/cow.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py index f880233ab..d3bf8ee2c 100644 --- a/implement-cowsay/cow.py +++ b/implement-cowsay/cow.py @@ -1,2 +1,21 @@ import cowsay -import sys +import argparse + +parser = argparse.ArgumentParser(prog="cow.py", + description="Print a message using a cowsay animal") + +parser.add_argument("message") +parser.add_argument("-a", + "--animal", + default="cow", + help="Animal to use for the speech bubble.") + +args = parser.parse_args() + +animal_names = cowsay.char_names + +if args.animal not in animal_names: + parser.error("The specified animal is not found in the cowsay animal list.") + +animal_function = getattr(cowsay, args.animal) +animal_function(args.message) From df73cf9bae59b14a81aac113b9b68d8027dc7de2 Mon Sep 17 00:00:00 2001 From: Ammad Date: Sun, 14 Jun 2026 16:32:12 +0100 Subject: [PATCH 3/7] Tidy up. --- implement-cowsay/cow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py index d3bf8ee2c..9f0c92fe8 100644 --- a/implement-cowsay/cow.py +++ b/implement-cowsay/cow.py @@ -1,5 +1,5 @@ -import cowsay import argparse +import cowsay parser = argparse.ArgumentParser(prog="cow.py", description="Print a message using a cowsay animal") From 23e32b27777cd136778f7d946bc6001960a416a4 Mon Sep 17 00:00:00 2001 From: Ammad Date: Wed, 24 Jun 2026 23:00:24 +0100 Subject: [PATCH 4/7] Improve .gitignore file. --- implement-cowsay/.gitignore | 220 +++++++++++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 1 deletion(-) diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore index a230a78ae..1e0c68ce1 100644 --- a/implement-cowsay/.gitignore +++ b/implement-cowsay/.gitignore @@ -1,2 +1,220 @@ -.venv/ +# Created by https://www.toptal.com/developers/gitignore/api/python,macos,osx +# Edit at https://www.toptal.com/developers/gitignore?templates=python,macos,osx + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### OSX ### +# General + +# Icon must end with two \r + +# Thumbnails + +# Files that might appear in the root of a volume + +# Directories potentially created on remote AFP share + +### Python ### +# Byte-compiled / optimized / DLL files __pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/python,macos,osx From 6b91fd0512014fe0ce7f141eae62cdf2b19b5da6 Mon Sep 17 00:00:00 2001 From: Ammad Date: Wed, 24 Jun 2026 23:09:27 +0100 Subject: [PATCH 5/7] Support multiple arguments. --- implement-cowsay/cow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py index 9f0c92fe8..4d2ece481 100644 --- a/implement-cowsay/cow.py +++ b/implement-cowsay/cow.py @@ -4,7 +4,9 @@ parser = argparse.ArgumentParser(prog="cow.py", description="Print a message using a cowsay animal") -parser.add_argument("message") +parser.add_argument("message", + nargs="+") + parser.add_argument("-a", "--animal", default="cow", @@ -18,4 +20,5 @@ parser.error("The specified animal is not found in the cowsay animal list.") animal_function = getattr(cowsay, args.animal) -animal_function(args.message) +user_input = " ".join(args.message) +animal_function(user_input) From f7f4ed24a47accd5fc794915d57ebfa7d9b3fe2f Mon Sep 17 00:00:00 2001 From: Ammad Date: Wed, 24 Jun 2026 23:27:11 +0100 Subject: [PATCH 6/7] Add suggestion for -a/--animal argument. --- implement-cowsay/cow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py index 4d2ece481..21a4d90f0 100644 --- a/implement-cowsay/cow.py +++ b/implement-cowsay/cow.py @@ -1,6 +1,8 @@ import argparse import cowsay +animal_names = cowsay.char_names + parser = argparse.ArgumentParser(prog="cow.py", description="Print a message using a cowsay animal") @@ -10,12 +12,11 @@ parser.add_argument("-a", "--animal", default="cow", + choices=animal_names, help="Animal to use for the speech bubble.") args = parser.parse_args() -animal_names = cowsay.char_names - if args.animal not in animal_names: parser.error("The specified animal is not found in the cowsay animal list.") From 94db083b3a05a9f4257b01551b787d9e1b15b53e Mon Sep 17 00:00:00 2001 From: Ammad Date: Wed, 24 Jun 2026 23:35:29 +0100 Subject: [PATCH 7/7] Amend the arguments parameters to match the README.md. --- implement-cowsay/cow.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py index 21a4d90f0..9126f6d69 100644 --- a/implement-cowsay/cow.py +++ b/implement-cowsay/cow.py @@ -3,14 +3,15 @@ animal_names = cowsay.char_names -parser = argparse.ArgumentParser(prog="cow.py", - description="Print a message using a cowsay animal") +parser = argparse.ArgumentParser(prog="cowsay", + description="Make animals say things") parser.add_argument("message", - nargs="+") + nargs="+", + help="The message to say.") -parser.add_argument("-a", - "--animal", +parser.add_argument("--animal", + "-a", default="cow", choices=animal_names, help="Animal to use for the speech bubble.")