diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 00000000..21d0b898 --- /dev/null +++ b/implement-cowsay/.gitignore @@ -0,0 +1 @@ +.venv/ diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 00000000..216a9409 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,17 @@ +import argparse +import cowsay + + +parser = argparse.ArgumentParser(description="implement Cowsay command") +parser.add_argument("text", help="Text to be displayed") +parser.add_argument("--animal", help="Animal to say the text", default="cow") +args = parser.parse_args() + +animals = cowsay.char_names +animal = args.animal.lower() +if animal not in animals: + print(f"Invalid animal. Supported animals are: {', '.join(animals)}") + exit(1) +cowsay.char_funcs[animal](args.text) + +