cli: Move settings option to subcommands.
This commit is contained in:
parent
c07c0ad30d
commit
a5737d91a8
|
@ -83,23 +83,22 @@ def print_version(ctx, param, value):
|
||||||
@click.option(
|
@click.option(
|
||||||
"--version", is_flag=True, callback=print_version, expose_value=False, is_eager=True
|
"--version", is_flag=True, callback=print_version, expose_value=False, is_eager=True
|
||||||
)
|
)
|
||||||
@settings_file_option
|
|
||||||
@pass_context
|
@pass_context
|
||||||
def mobilizon_reshare(ctx, settings_file):
|
def mobilizon_reshare():
|
||||||
ctx.ensure_object(dict)
|
pass
|
||||||
ctx.obj["settings-file"] = settings_file
|
|
||||||
|
|
||||||
|
|
||||||
@mobilizon_reshare.command(help="Synchronize and publish events.")
|
@mobilizon_reshare.command(help="Synchronize and publish events.")
|
||||||
def start(ctx):
|
@settings_file_option
|
||||||
|
def start(ctx, settings):
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
safe_execution(start_main, settings_file=ctx.obj["settings-file"])
|
safe_execution(start_main, settings_file=settings)
|
||||||
|
|
||||||
|
|
||||||
@mobilizon_reshare.command(help="Publish a recap of already published events.")
|
@mobilizon_reshare.command(help="Publish a recap of already published events.")
|
||||||
def recap(ctx):
|
@settings_file_option
|
||||||
ctx.ensure_object(dict)
|
def recap(settings):
|
||||||
safe_execution(recap_main, settings_file=ctx.obj["settings-file"])
|
safe_execution(recap_main, settings_file=settings)
|
||||||
|
|
||||||
|
|
||||||
@mobilizon_reshare.group(help="List objects in the database with different criteria.")
|
@mobilizon_reshare.group(help="List objects in the database with different criteria.")
|
||||||
|
@ -114,8 +113,9 @@ def inspect(ctx, begin, end):
|
||||||
|
|
||||||
@inspect.command(help="Query for events in the database.")
|
@inspect.command(help="Query for events in the database.")
|
||||||
@event_status_option
|
@event_status_option
|
||||||
|
@settings_file_option
|
||||||
@pass_context
|
@pass_context
|
||||||
def event(ctx, status):
|
def event(ctx, status, settings):
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
safe_execution(
|
safe_execution(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
|
@ -124,14 +124,15 @@ def event(ctx, status):
|
||||||
frm=ctx.obj["begin"],
|
frm=ctx.obj["begin"],
|
||||||
to=ctx.obj["end"],
|
to=ctx.obj["end"],
|
||||||
),
|
),
|
||||||
ctx.obj["settings-file"],
|
settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@inspect.command(help="Query for publications in the database.")
|
@inspect.command(help="Query for publications in the database.")
|
||||||
@publication_status_option
|
@publication_status_option
|
||||||
|
@settings_file_option
|
||||||
@pass_context
|
@pass_context
|
||||||
def publication(ctx, status):
|
def publication(ctx, status, settings):
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
safe_execution(
|
safe_execution(
|
||||||
functools.partial(
|
functools.partial(
|
||||||
|
@ -140,7 +141,7 @@ def publication(ctx, status):
|
||||||
frm=ctx.obj["begin"],
|
frm=ctx.obj["begin"],
|
||||||
to=ctx.obj["end"],
|
to=ctx.obj["end"],
|
||||||
),
|
),
|
||||||
ctx.obj["settings-file"],
|
settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,13 +149,12 @@ def publication(ctx, status):
|
||||||
help="Format and print event with EVENT-ID using the publisher's format named "
|
help="Format and print event with EVENT-ID using the publisher's format named "
|
||||||
"PUBLISHER."
|
"PUBLISHER."
|
||||||
)
|
)
|
||||||
@settings_file_option
|
|
||||||
@click.argument("event-id", type=click.UUID)
|
@click.argument("event-id", type=click.UUID)
|
||||||
@click.argument("publisher", type=click.Choice(publisher_names))
|
@click.argument("publisher", type=click.Choice(publisher_names))
|
||||||
def format(ctx, event_id, publisher):
|
@settings_file_option
|
||||||
ctx.ensure_object(dict)
|
def format(event_id, publisher, settings):
|
||||||
safe_execution(
|
safe_execution(
|
||||||
functools.partial(format_event, event_id, publisher), ctx.obj["settings-file"],
|
functools.partial(format_event, event_id, publisher), settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue