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 0bd44cc commit abb66cfCopy full SHA for abb66cf
1 file changed
implement-cowsay/cow.py
@@ -1,2 +1,21 @@
1
import cowsay
2
-import sys
+import argparse
3
+
4
+parser = argparse.ArgumentParser(prog="cow.py",
5
+ description="Print a message using a cowsay animal")
6
7
+parser.add_argument("message")
8
+parser.add_argument("-a",
9
+ "--animal",
10
+ default="cow",
11
+ help="Animal to use for the speech bubble.")
12
13
+args = parser.parse_args()
14
15
+animal_names = cowsay.char_names
16
17
+if args.animal not in animal_names:
18
+ parser.error("The specified animal is not found in the cowsay animal list.")
19
20
+animal_function = getattr(cowsay, args.animal)
21
+animal_function(args.message)
0 commit comments