diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -54,6 +54,8 @@ entry_points=''' [console_scripts] swh-lister=swh.lister.cli:cli + [swh.cli.subcommands] + lister=swh.lister.cli:lister ''', classifiers=[ "Programming Language :: Python :: 3", diff --git a/swh/lister/cli.py b/swh/lister/cli.py --- a/swh/lister/cli.py +++ b/swh/lister/cli.py @@ -6,6 +6,8 @@ import logging import click +from swh.core.cli import CONTEXT_SETTINGS + logger = logging.getLogger(__name__) @@ -13,7 +15,14 @@ '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 @@ 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 = {