diff --git a/implement-cowsay/.gitignore b/implement-cowsay/.gitignore new file mode 100644 index 00000000..b694934f --- /dev/null +++ b/implement-cowsay/.gitignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/implement-cowsay/anisay.py b/implement-cowsay/anisay.py new file mode 100644 index 00000000..c1f93ab6 --- /dev/null +++ b/implement-cowsay/anisay.py @@ -0,0 +1,32 @@ +import argparse +import cowsay #to do the ascii art with animals + +def main(): + #getlistof animals within cowsay + animals = cowsay.char_names + #create a parser for command line argument + parser = argparse.ArgumentParser( + description="Make animals say things!" + ) + parser.add_argument( + '--animal', '-a', + choices=animals, + default='cow', + help='The animal to be saying things (default: cow)' + ) + #argument for the message + parser.add_argument('message',nargs='+',help='The message to say') + #to parse the arguments from the command line + args = parser.parse_args() + #the messageword into a single string + text = ' '.join(args.message) + + try: + output = cowsay.get_output_string(char=args.animal, text=text) + print(output) + except cowsay.CowsayError as e: + print(f"Error: {e}") + exit(1) +#run main function only if this script is run directly +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/implement-cowsay/requirements.txt b/implement-cowsay/requirements.txt new file mode 100644 index 00000000..cc557103 --- /dev/null +++ b/implement-cowsay/requirements.txt @@ -0,0 +1 @@ +cowsay \ No newline at end of file