Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d64a62d
create a .py file and a venv
HassanOHOsman Nov 28, 2025
9ed0feb
create requirements.txt file with cowsay library listed on it
HassanOHOsman Nov 28, 2025
5056da5
import cowsay & sys into the .py file
HassanOHOsman Nov 28, 2025
3e46eb0
install cowsay library
HassanOHOsman Nov 28, 2025
9dbaa8f
skip the first argument which is our program name and them join the r…
HassanOHOsman Nov 28, 2025
98cea7c
since sys is built-in no point of explicity saying import
HassanOHOsman Nov 30, 2025
e09ede3
import argparse & sys libraries
HassanOHOsman Nov 30, 2025
56afb4f
define programme medta data
HassanOHOsman Nov 30, 2025
778321f
add --animal and define it's purpose
HassanOHOsman Nov 30, 2025
e8e7d09
add defintion for the message argument
HassanOHOsman Nov 30, 2025
55d9cc9
read the command line in terminal
HassanOHOsman Nov 30, 2025
cdc3bdd
stored the message written in a variable called message
HassanOHOsman Nov 30, 2025
7d49667
var animal represents the animal selected by end user otherwise defau…
HassanOHOsman Nov 30, 2025
827e134
make the function dynamic to print an the image of the selected animal
HassanOHOsman Nov 30, 2025
6490896
print to the console what each animal in the cowsay object has to say
HassanOHOsman Nov 30, 2025
fa626b4
fetching the animals in cowsay library
HassanOHOsman Nov 30, 2025
4bfcbb4
correcting buggy fetching
HassanOHOsman Nov 30, 2025
35ecdac
Show printed error message to help end user select from listed animal…
HassanOHOsman Nov 30, 2025
f39e5b5
update the --help option content to show the range of animal options …
HassanOHOsman Nov 30, 2025
49a4340
create .gitignore file to ignore the .venv
HassanOHOsman Jan 9, 2026
60cfbdf
remove all .venv files
HassanOHOsman Jan 9, 2026
2d9d0c4
make listed_animal more dynamic rather than hardcoded
HassanOHOsman Jan 13, 2026
01c6b73
dynamic fetching
HassanOHOsman Jan 13, 2026
128b09d
make default argument handlded inside the parser for animal flag
HassanOHOsman Jan 13, 2026
e58e3e0
discard code lines no longer in use
HassanOHOsman Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions implement-cowsay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.venv/
.env
.env.*

23 changes: 23 additions & 0 deletions implement-cowsay/cow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import cowsay
import argparse

listed_animals = cowsay.char_names

parser = argparse.ArgumentParser(
prog="cow",
description="Makes animals say things",
)

parser.add_argument("--animal", default="cow", help="Select an animal to say anything", choices=listed_animals)
parser.add_argument("message", nargs ="+", help="The message that the animal says")

args = parser.parse_args()

message = " ".join(args.message)
animal = args.animal


animal_says = getattr(cowsay, animal)

print(animal_says(message))

1 change: 1 addition & 0 deletions implement-cowsay/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsay==6.1