File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 11node_modules
2+ .venv
Original file line number Diff line number Diff line change 1+ import argparse
2+ import cowsay
3+
4+ def main ():
5+ # Set up argument parser
6+ parser = argparse .ArgumentParser (description = "Make animals say things" )
7+ parser .add_argument ("message" , nargs = "+" , help = "The message to say." )
8+ parser .add_argument (
9+ "--animal" ,
10+ choices = cowsay .char_names ,
11+ default = "cow" ,
12+ help = "The animal to be saying things." ,
13+ )
14+
15+ args = parser .parse_args ()
16+
17+ # Combine the message into a single string
18+ message = " " .join (args .message )
19+
20+ # Get the animal function dynamically
21+ animal_function = getattr (cowsay , args .animal , cowsay .cow )
22+
23+ # Print the message using the selected animal
24+ print (animal_function (message ))
25+
26+ if __name__ == "__main__" :
27+ main ()
Original file line number Diff line number Diff line change 1+ cowsay
You can’t perform that action at this time.
0 commit comments