Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cli.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
import click | import click | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', 'npm'] | SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi', 'npm'] | ||||
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) | |||||
@click.command() | @click.command(name='lister', context_settings=CONTEXT_SETTINGS) | ||||
@click.option( | @click.option( | ||||
'--db-url', '-d', default='postgres:///lister-gitlab.com', | '--db-url', '-d', default='postgres:///lister-gitlab.com', | ||||
help='SQLAlchemy DB URL; see ' | help='SQLAlchemy DB URL; see ' | ||||
'<http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls>') # noqa | '<http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls>') # noqa | ||||
@click.argument('listers', required=1, nargs=-1, | @click.argument('listers', required=1, nargs=-1, | ||||
type=click.Choice(SUPPORTED_LISTERS + ['all'])) | type=click.Choice(SUPPORTED_LISTERS + ['all'])) | ||||
@click.option('--drop-tables', '-D', is_flag=True, default=False, | @click.option('--drop-tables', '-D', is_flag=True, default=False, | ||||
help='Drop tables before creating the database schema') | help='Drop tables before creating the database schema') | ||||
def cli(db_url, listers, drop_tables): | @click.pass_context | ||||
"""Initialize db model according to lister. | def cli(ctx, db_url, listers, drop_tables): | ||||
"""Initialize the db model for the given listers. | |||||
""" | """ | ||||
override_conf = { | override_conf = { | ||||
'lister': { | 'lister': { | ||||
'cls': 'local', | 'cls': 'local', | ||||
'args': {'db': db_url} | 'args': {'db': db_url} | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |