mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Catch missing TODOIST_API_KEY before calling into click cli since it breaks --help
This commit is contained in:
parent
2e5d6e8ac8
commit
7a61b82130
16
migrate.py
16
migrate.py
@ -1,5 +1,6 @@
|
|||||||
import click
|
import click
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from taskw import TaskWarrior
|
from taskw import TaskWarrior
|
||||||
from todoist.api import TodoistAPI
|
from todoist.api import TodoistAPI
|
||||||
@ -10,13 +11,8 @@ taskwarrior = None
|
|||||||
""" CLI Commands """
|
""" CLI Commands """
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.option('--todoist-api-key', envvar='TODOIST_API_KEY', required=True)
|
def cli():
|
||||||
def cli(todoist_api_key):
|
pass
|
||||||
# Just do some initialization
|
|
||||||
global todoist
|
|
||||||
global taskwarrior
|
|
||||||
todoist = TodoistAPI(todoist_api_key)
|
|
||||||
taskwarrior = TaskWarrior()
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@ -145,5 +141,11 @@ def _match_weekly(desc):
|
|||||||
""" Entrypoint """
|
""" Entrypoint """
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
todoist_api_key = os.getenv('TODOIST_API_KEY')
|
||||||
|
if todoist_api_key is None:
|
||||||
|
exit('TODOIST_API_KEY environment variable not specified. Exiting.')
|
||||||
|
|
||||||
|
todoist = TodoistAPI(todoist_api_key)
|
||||||
|
taskwarrior = TaskWarrior()
|
||||||
cli()
|
cli()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user