cli.py 840 Bytes
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)