diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c840759 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Environments +venv/ + diff --git a/migrate.py b/migrate.py new file mode 100644 index 0000000..07f3ee2 --- /dev/null +++ b/migrate.py @@ -0,0 +1,48 @@ +import click +from taskw import TaskWarrior +from todoist.api import TodoistAPI + +todoist = None +taskwarrior = None + +""" CLI Commands """ + +@click.group() +@click.option('--todoist-api-key', envvar='TODOIST_API_KEY', required=True) +def cli(todoist_api_key): + # Just do some initialization + global todoist + global taskwarrior + todoist = TodoistAPI(todoist_api_key) + taskwarrior = TaskWarrior() + + +@cli.command() +@click.option('-i', '--interactive', default=False) +def migrate(interactive): + important('Starting migration...') + # todoist.sync() + tasks = todoist.items.all() + + info(f'Todoist tasks: {len(todoist.items.all())}') + for task in todoist.items.all(): + tid = task['id'] + name = task['content'] + info(f'Importing task #{tid}: {name}') + taskwarrior.task_add(name) + +""" Utils """ + +def important(msg): + click.echo(click.style(msg, fg='blue', bold=True)) + + +def info(msg): + click.echo(msg) + + +""" Entrypoint """ + +if __name__ == '__main__': + cli() + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b4c4682 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Click==7.0 +taskw==1.2.0 +todoist-python==7.0.18 +