diff --git a/implement-cowsay/cow.py b/implement-cowsay/cow.py new file mode 100644 index 000000000..359690400 --- /dev/null +++ b/implement-cowsay/cow.py @@ -0,0 +1,16 @@ +import cowsay +import argparse + +animals = cowsay.char_names; + +parser = argparse.ArgumentParser(prog="cowsay", description="Make animals say things", usage="%(prog)s [-h] [--animal {" + ",".join(animals) + "}] message [message ...]") +parser.add_argument("--animal", help="{"+ ",".join(animals) +"} \nThe animal to be saying things.", default="cow") +parser.add_argument("message", help="The message to say.", nargs="+") + +args = parser.parse_args() + +if args.animal not in cowsay.char_names: + parser.print_usage() + print("cowsay: error: argument --animal: invalid choice: '" + args.animal + "' (choose from '" + "', '".join(animals) + "')") +else: + print(cowsay.get_output_string(args.animal, " ".join(args.message[0:]))) \ No newline at end of file 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