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 3f26722 commit 58619f1Copy full SHA for 58619f1
1 file changed
implement-cowsay/cow.py
@@ -0,0 +1,30 @@
1
+import argparse
2
+import cowsay
3
+
4
5
+parser = argparse.ArgumentParser(description="Make animals say things")
6
7
+# Get supported animals from cowsay library
8
+animals = list(cowsay.char_funcs.keys())
9
10
+parser.add_argument(
11
+ "message",
12
+ nargs="+",
13
+ help="The message to say."
14
+)
15
16
17
+ "--animal",
18
+ choices=animals,
19
+ default="cow",
20
+ help="The animal to be saying things."
21
22
23
+args = parser.parse_args()
24
25
+message = " ".join(args.message)
26
27
+# Call the selected animal function from cowsay
28
+animal = getattr(cowsay, args.animal)
29
30
+animal(message)
0 commit comments