Factor out synchronize command to update local todoist database

This commit is contained in:
Matt Snider 2019-03-23 20:56:26 +01:00
parent 6a795da284
commit 453f8d1e28
1 changed files with 14 additions and 6 deletions

View File

@ -16,14 +16,22 @@ def cli():
pass
@cli.command()
def synchronize():
"""Sync the local task database and then exit. """
important('Syncing tasks with todoist... ', nl=False)
todoist.sync()
success('OK')
@cli.command()
@click.option('-i', '--interactive', is_flag=True, default=False)
@click.option('--no-sync', is_flag=True, default=False)
def migrate(interactive, no_sync):
if not no_sync:
important('Syncing tasks with todoist... ', nl=False)
todoist.sync()
success('OK')
@click.option('--sync/--no-sync', default=True)
@click.pass_context
def migrate(ctx, interactive, sync):
if sync:
ctx.invoke(synchronize)
tasks = todoist.items.all()
important(f'Starting migration of {len(tasks)}...\n')