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 70d3155 commit 9c2819eCopy full SHA for 9c2819e
implement-cowsay/cow.py
@@ -0,0 +1,36 @@
1
+import argparse
2
+import cowsay
3
+
4
+def main():
5
+ # List of available animals (provided by the package)
6
+ animals = cowsay.char_names
7
8
+ parser = argparse.ArgumentParser(
9
+ prog="cowsay",
10
+ description="Make animals say things"
11
+ )
12
13
+ parser.add_argument(
14
+ "message",
15
+ nargs="+",
16
+ help="The message to say."
17
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
28
+ message = " ".join(args.message)
29
30
+ # Dynamically call the function for the chosen animal
31
+ animal_func = getattr(cowsay, args.animal)
32
+ print(animal_func(message))
33
34
35
+if __name__ == "__main__":
36
+ main()
0 commit comments