File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ import argparse
3+ import cowsay
4+
5+ def main ():
6+
7+ animals = sorted (cowsay .char_names )
8+
9+ parser = argparse .ArgumentParser (
10+ prog = 'cowsay' ,
11+ description = 'Make animals say things'
12+ )
13+ parser .add_argument (
14+ '--animal' ,
15+ choices = animals ,
16+ default = 'cow' ,
17+ help = 'The animal to be saying things.'
18+ )
19+ parser .add_argument (
20+ 'message' ,
21+ nargs = '+' ,
22+ help = 'The message to say.'
23+ )
24+
25+ args = parser .parse_args ()
26+ text = " " .join (args .message )
27+
28+ getattr (cowsay , args .animal )(text )
29+
30+ if __name__ == '__main__' :
31+ main ()
Original file line number Diff line number Diff line change 1+ certifi == 2025.7.14
2+ charset-normalizer == 3.4.2
3+ cowsay == 5.0
4+ idna == 3.10
5+ requests == 2.32.4
6+ urllib3 == 2.5.0
You can’t perform that action at this time.
0 commit comments