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 d7f15ff commit bcbc953Copy full SHA for bcbc953
1 file changed
implement-cowsay/cow.py
@@ -0,0 +1,29 @@
1
+import cowsay
2
+import argparse
3
+
4
+# get valid animals dynamically from the library
5
+animals = [
6
+ name for name in dir(cowsay)
7
+ if name.islower() and callable(getattr(cowsay, name))
8
+]
9
10
+parser = argparse.ArgumentParser(description="Make animals say things")
11
12
+parser.add_argument(
13
+ "message",
14
+ nargs="+",
15
+ help="The message to say."
16
+)
17
18
19
+ "--animal",
20
+ choices=animals,
21
+ default="cow",
22
+ help="The animal to be saying things."
23
24
25
+args = parser.parse_args()
26
27
+message = " ".join(args.message)
28
29
+getattr(cowsay, args.animal)(message)
0 commit comments