File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import cowsay
22import argparse
33
4+ animals = cowsay .char_names
5+
46parser = argparse .ArgumentParser (
57 prog = "cowsay" ,
68 description = "Make animals say things"
79)
810
9- parser .add_argument ("-- animal" , help = "The animal to be saying things." )
11+ parser .add_argument ("-a" , "-- animal", choices = animals , help = "The animal to be saying things." )
1012parser .add_argument ("message" , nargs = "+" , help = "The message to say." )
1113
1214args = parser .parse_args ()
1315
14- # cowsay.cow( " ".join(sys.argv[1:]) )
16+ message = " " .join (args . message )
1517
18+ print (args )
1619
17- animals = cowsay .char_names
20+ if args .animal :
21+ # cowsay[args.animal](message)
22+ print (cowsay .get_output_string (args .animal , message ))
23+ # print('hi')
24+ else :
25+ # print(cowsay.get_output_string('cow', 'Hello World'))
26+ cowsay .cow (message ) # if no animal is provided, use default
27+
28+
29+
30+ print (animals )
1831
19- print ( animals )
32+
You can’t perform that action at this time.
0 commit comments