From b71692a41e9ae590fbba373d274052da1ac3efe7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 19 Sep 2019 09:10:52 +0100 Subject: [PATCH] Add CLI command to list todoist project ids --- actioner/cli/__init__.py | 14 ++++++++++++++ actioner/main.py | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 actioner/cli/__init__.py diff --git a/actioner/cli/__init__.py b/actioner/cli/__init__.py new file mode 100644 index 0000000..9541fa8 --- /dev/null +++ b/actioner/cli/__init__.py @@ -0,0 +1,14 @@ +import click + +from actioner.clients import get_todoist_client + + +def list_todoist_projects(): + todoist = get_todoist_client() + todoist.projects.sync() + + for project in todoist.state["projects"]: + click.echo("'{}' has id {}".format(project["name"], project["id"])) + + +CLI_ENTRYPOINTS = [list_todoist_projects] diff --git a/actioner/main.py b/actioner/main.py index 5a74503..2ea8fb0 100644 --- a/actioner/main.py +++ b/actioner/main.py @@ -5,6 +5,7 @@ import click import sentry_sdk from apscheduler.util import get_callable_name +from actioner.cli import CLI_ENTRYPOINTS from actioner.scheduler import create_scheduler from actioner.settings import LOGGING_LEVEL, SENTRY_DSN from actioner.web import get_server, run_server @@ -33,5 +34,9 @@ def once(): job() +for entry_point in CLI_ENTRYPOINTS: + cli.command()(entry_point) + + if __name__ == "__main__": cli()