We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 407b010 commit c634395Copy full SHA for c634395
1 file changed
implement-cowsay/cow.py
@@ -0,0 +1,34 @@
1
+#!/usr/bin/env python3
2
+import argparse
3
+import sys
4
+import cowsay
5
+
6
+def main():
7
+ # Dynamically get available animals from the cowsay library
8
+ animals = sorted(cowsay.char_names)
9
10
+ parser = argparse.ArgumentParser(
11
+ prog="cowsay",
12
+ description="Make animals say things"
13
+ )
14
+ parser.add_argument(
15
+ "message",
16
+ nargs="+",
17
+ help="The message to say."
18
19
20
+ "--animal",
21
+ choices=animals,
22
+ default="cow",
23
+ help="The animal to be saying things."
24
25
26
+ args = parser.parse_args()
27
+ msg = " ".join(args.message)
28
29
+ # Render the chosen animal saying the message
30
+ output = cowsay.get_output_string(args.animal, msg)
31
+ sys.stdout.write(output + "\n")
32
33
+if __name__ == "__main__":
34
+ main()
0 commit comments