cli: register the 'lister' cli subcommand
also add a cli group named 'lister' for the sake of consistency with other swh packages and rename the command as 'db-init', like: swh lister db-init LISTER [...]
This commit is contained in:
parent
701d833cdf
commit
d6169c7141
2 changed files with 15 additions and 3 deletions
2
setup.py
2
setup.py
|
@ -54,6 +54,8 @@ setup(
|
|||
entry_points='''
|
||||
[console_scripts]
|
||||
swh-lister=swh.lister.cli:cli
|
||||
[swh.cli.subcommands]
|
||||
lister=swh.lister.cli:lister
|
||||
''',
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
import logging
|
||||
import click
|
||||
|
||||
from swh.core.cli import CONTEXT_SETTINGS
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -13,7 +15,14 @@ SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi',
|
|||
'npm', 'phabricator']
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.group(name='lister', context_settings=CONTEXT_SETTINGS)
|
||||
@click.pass_context
|
||||
def lister(ctx):
|
||||
'''Software Heritage Lister tools.'''
|
||||
pass
|
||||
|
||||
|
||||
@lister.command(name='db-init', context_settings=CONTEXT_SETTINGS)
|
||||
@click.option(
|
||||
'--db-url', '-d', default='postgres:///lister-gitlab.com',
|
||||
help='SQLAlchemy DB URL; see '
|
||||
|
@ -22,8 +31,9 @@ SUPPORTED_LISTERS = ['github', 'gitlab', 'bitbucket', 'debian', 'pypi',
|
|||
type=click.Choice(SUPPORTED_LISTERS + ['all']))
|
||||
@click.option('--drop-tables', '-D', is_flag=True, default=False,
|
||||
help='Drop tables before creating the database schema')
|
||||
def cli(db_url, listers, drop_tables):
|
||||
"""Initialize db model according to lister.
|
||||
@click.pass_context
|
||||
def cli(ctx, db_url, listers, drop_tables):
|
||||
"""Initialize the database model for given listers.
|
||||
|
||||
"""
|
||||
override_conf = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue