File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import argparse
2+ from email import message
3+ import cowsay
4+
5+ def main ():
6+ #Get the list of animals from cowsay library
7+ animals = sorted (cowsay .char_names )
8+ parser = argparse .ArgumentParser (
9+ prog = "cowsay" ,
10+ description = "Make animal say things"
11+ )
12+
13+ parser .add_argument (
14+ "--animal" ,
15+ choices = animals ,
16+ default = "cow" ,
17+ help = "The animal to say the message."
18+ )
19+ parser .add_argument (
20+ "message" ,
21+ nargs = "+" ,
22+ help = "The message to be said by the animal."
23+ )
24+
25+ args = parser .parse_args ()
26+ # Join message list into a single string
27+ text = " " .join (args .message )
28+ # Default animal is "cow" if not specified
29+ print (cowsay .get_output_string (args .animal , text ))
30+
31+ if __name__ == "__main__" :
32+ main ()
You can’t perform that action at this time.
0 commit comments