-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.py
37 lines (26 loc) · 905 Bytes
/
module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
example of module packaged with code in main function, accepting command line args.
"""
import argparse
def func1():
pass
def func2():
pass
def main(client_name=None, client_id=None, dry_run=None):
print('function main has args:', client_name, client_id, dry_run)
pass
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--client_name', type=str,
help='A optional string argument')
parser.add_argument('--client_id', type=str,
help='An optional string argument')
parser.add_argument('--dry_run', action='store_true',
help='A boolean switch')
args = parser.parse_args()
main(
client_name=args.client_name,
client_id=args.client_id,
dry_run=args.dry_run,
)
#main(**vars(args)) <- this also works if you want to be less explicit