File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed
source-code/command-line-arguments Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ # Fire
2+
3+ The Google Fire library can be used to (almost) effortlessly create
4+ applications with a command line interface.
5+
6+ ## What is it?
7+
8+ 1 . ` calculator.py ` : Calculator application that implements addition
9+ and multiplication.
10+ 1 . ` sayer.py ` : Illustration of grouped commands.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ import fire
3+
4+
5+ def add (x , y ):
6+ return x + y
7+
8+ def mult (x , y ):
9+ return x * y
10+
11+
12+ if __name__ == '__main__' :
13+ fire .Fire ()
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import fire
4+
5+
6+ class Hello :
7+
8+ def __init__ (self , name ):
9+ self .name = name
10+
11+ def say (self ):
12+ return f'Hello { self .name } '
13+
14+ class Bye :
15+
16+ def __init__ (self , name ):
17+ self .name = name
18+
19+ def say (self ):
20+ return f'Bye { self .name } '
21+
22+
23+ class Sayer :
24+
25+ def __init__ (self , hello_name , bye_name ):
26+ self .hello = Hello (hello_name )
27+ self .bye = Bye (bye_name )
28+
29+ def say (self ):
30+ return f'Bla, bla'
31+
32+ if __name__ == '__main__' :
33+ fire .Fire (Sayer )
Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ How to handle command line arguments in Python scripts.
77 to handle command line arguments.
88 1 . ` Click ` : illustration of how to use the click module
99 to handle command line arguments.
10+ 1 . ` Fire ` : command line applications using Google Fire.
You can’t perform that action at this time.
0 commit comments