diff --git a/todoist_taskwarrior/cli.py b/todoist_taskwarrior/cli.py index 26eff76..1a16a5c 100644 --- a/todoist_taskwarrior/cli.py +++ b/todoist_taskwarrior/cli.py @@ -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')