cli: Make cli work with new lister

while allowing legacy lister to still run (with --legacy)
This commit is contained in:
Antoine R. Dumont (@ardumont) 2021-01-27 18:28:09 +01:00
parent cbd2cce339
commit 17b0e7af26
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8

View file

@ -129,9 +129,10 @@ def db_init(ctx, drop_tables):
type=click.Choice(["high", "medium", "low"]),
help="Task priority for the listed repositories to ingest",
)
@click.option("--legacy", help="Allow unported lister to run with such flag")
@click.argument("options", nargs=-1)
@click.pass_context
def run(ctx, lister, priority, options):
def run(ctx, lister, priority, options, legacy):
from swh.scheduler.cli.utils import parse_options
config = deepcopy(ctx.obj["config"])
@ -139,8 +140,9 @@ def run(ctx, lister, priority, options):
if options:
config.update(parse_options(options)[1])
config["priority"] = priority
config["policy"] = "oneshot"
if legacy:
config["priority"] = priority
config["policy"] = "oneshot"
get_lister(lister, **config).run()