cli.py
840 Bytes
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
import argparse
import logging
def add_some_parser(subparsers):
parser = subparsers.add_parser('load-data',
help='Loads crawled data into a database',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--input-folder', help='Input folder',
default='data/crawl/json')
def execute_load_data(args):
print(f'Loading data with args: {args}')
def main():
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='cmd')
subparsers.required = True
add_some_parser(subparsers)
args = parser.parse_args()
print(args)
logging.info(args)
cmd = args.cmd
if cmd == 'load-data':
execute_load_data(args)