diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..6071e89b1 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,28 @@ +import cowsay +import sys + + +def main(): + animal = "" + args = sys.argv[1:] + if len(args) == 0: + print("error: no arguments provided.") + return + if args[0] == "--animal" and len(args) > 1: + animal = args[1] + elif args[0] != "--animal": + animal = "cow" + message = "" + for i in range(2,len(args)): + message += args[i] + + try: + getattr(cowsay, animal)(message) + except Exception as e: + if animal == "": + print("error: argument --animal: invalid choice: empty string, choose from 'beavis', 'cheese', 'cow', 'daemon', 'dragon', 'fox', 'ghostbusters', 'kitty', 'meow', 'miki', 'milk', 'octopus', 'pig', 'stegosaurus', 'stimpy', 'trex', 'turkey', 'turtle', 'tux'") + else: + print("error: argument --animal: invalid choice: " + animal + ", choose from 'beavis', 'cheese', 'cow', 'daemon', 'dragon', 'fox', 'ghostbusters', 'kitty', 'meow', 'miki', 'milk', 'octopus', 'pig', 'stegosaurus', 'stimpy', 'trex', 'turkey', 'turtle', 'tux'") + +if __name__ == "__main__": + main() 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