mirror of
https://git.webmeisterei.com/webmeisterei/todoist-taskwarrior.git
synced 2023-12-21 10:23:00 +01:00
Add clean
command to remove todoist cache
This commit is contained in:
parent
176ee0119c
commit
b624aa77e6
@ -6,9 +6,16 @@ from taskw import TaskWarrior
|
||||
from todoist.api import TodoistAPI
|
||||
from . import utils, io
|
||||
|
||||
|
||||
# This is the location where the todoist
|
||||
# data will be cached.
|
||||
TODOIST_CACHE = '~/.todoist-sync/'
|
||||
|
||||
|
||||
todoist = None
|
||||
taskwarrior = None
|
||||
|
||||
|
||||
""" CLI Commands """
|
||||
|
||||
@click.group()
|
||||
@ -33,6 +40,27 @@ def synchronize():
|
||||
todoist.sync()
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.confirmation_option(prompt=f'Are you sure you want to delete {TODOIST_CACHE}?')
|
||||
def clean():
|
||||
"""Remove the data stored in the Todoist task cache.
|
||||
|
||||
NOTE - the local Todoist data cache is usually located at:
|
||||
|
||||
~/.todoist-sync
|
||||
"""
|
||||
cache_dir = os.path.expanduser(TODOIST_CACHE)
|
||||
|
||||
# Delete all files in directory
|
||||
for file_entry in os.scandir(cache_dir):
|
||||
with io.with_feedback(f'Removing file {file_entry.path}'):
|
||||
os.remove(file_entry)
|
||||
|
||||
# Delete directory
|
||||
with io.with_feedback(f'Removing directory {cache_dir}'):
|
||||
os.rmdir(cache_dir)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('-i', '--interactive', is_flag=True, default=False,
|
||||
help='Interactively choose which tasks to import and modify them '
|
||||
@ -198,7 +226,7 @@ if __name__ == '__main__':
|
||||
io.error('TODOIST_API_KEY environment variable not specified. Exiting.')
|
||||
exit(1)
|
||||
|
||||
todoist = TodoistAPI(todoist_api_key)
|
||||
todoist = TodoistAPI(todoist_api_key, cache=TODOIST_CACHE)
|
||||
|
||||
# Create the TaskWarrior client, overriding config to
|
||||
# create a `todoist_id` field which we'll use to
|
||||
|
Loading…
Reference in New Issue
Block a user