main.py 829 字节
Newer Older
1 2 3
import click
import tag_source.vscode
import tag_source.stackoverflow
F
feilong 已提交
4
import tag_source.segmentfault
F
feilong 已提交
5 6
import tag_source.infoq
import tag_source.cnblogs
F
feilong 已提交
7
import tag_source.oschina
8 9 10 11 12

@click.command()
@click.option('--source')
def fetch(source):
    click.echo('will fetch tags from %s!' % source)
F
feilong 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

    sources = {
        'vscode': lambda: tag_source.vscode.fetch(),
        'so': lambda: tag_source.stackoverflow.fetch(),
        'sf': lambda: tag_source.segmentfault.fetch(),
        'infoq': lambda: tag_source.infoq.fetch(),
        'cnblogs': lambda: tag_source.cnblogs.fetch(),
        'oschina': lambda: tag_source.oschina.fetch(),
    }

    action = sources.get(source)
    if action is not None:
        action()
    else:
        print('source {} is not support now.'.format(source))
28 29 30

if __name__ == '__main__':
    fetch()