File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed
Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change 44
55parser = argparse .ArgumentParser (prog = "cowsay" ,
66 description = "Make animals say things." )
7- parser .add_argument ("message" ,help = "The message to say." )
7+ parser .add_argument ("message" ,nargs = "+" , help = "The message to say." )
88valid_animals = cowsay .char_names ;
99parser .add_argument ("--animal" ,
1010 choices = valid_animals ,
1111 help = " The animal to be saying things." ,
1212 default = "cow" )
1313
1414args = parser .parse_args ();
15- getattr (cowsay ,args .animal )(args .message )
16- # args=sys.argv[1:]
17- # print(sys.argv)
18- # flags=list(filter(lambda arg : arg.startswith("-"),args))
19- # print(flags)
20- # validAnimals=cowsay.char_names;
21- # print(validAnimals)
15+ getattr (cowsay ,args .animal )(" " .join (args .message ))
2216
23- # if len(flags)==0 :
24- # cowsay.cow(" ".join(sys.argv[1:]))
25- # elif "--help" in flags or "--h" in flags :
26- # print("help!!!!!!!!!!!!!!!!")
27- # elif "--animal" in flags :
28- # animalName=args[args.index("--animal")+1]
29- # print(animalName)
30- # message=" ".join(args[args.index("--animal")+2:])
31- # print(message)
32- # if hasattr(cowsay,animalName) :
33- # getattr(cowsay,animalName)(message)
3417
You can’t perform that action at this time.
0 commit comments