1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
todoist-github/todoist_github/cli.py

43 lines
800 B
Python
Raw Normal View History

2020-01-08 20:17:53 +00:00
#!/usr/bin/env python3
2020-01-19 19:51:44 +00:00
import argparse
2020-01-19 20:04:14 +00:00
import logging
2020-01-19 19:51:44 +00:00
import time
2020-01-19 20:04:14 +00:00
2020-01-19 20:02:13 +00:00
import coloredlogs
2020-01-19 19:51:44 +00:00
2020-01-19 20:24:08 +00:00
from .clients import todoist
from .tasks import ALL_TASKS
2020-01-19 19:51:44 +00:00
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--interval", type=int, default=0)
return parser.parse_args()
def run_tasks():
for task in ALL_TASKS:
2020-01-19 20:02:13 +00:00
logging.info("Executing %s", task.__name__)
2020-01-09 18:25:38 +00:00
task()
logging.info("Committing tasks")
2020-01-19 20:24:08 +00:00
todoist.commit()
2020-01-08 21:05:58 +00:00
2020-01-19 19:51:44 +00:00
def main():
2020-01-19 20:02:13 +00:00
coloredlogs.install(
level=logging.INFO,
fmt="%(asctime)s %(levelname)s %(message)s",
datefmt="%H:%M:%S",
)
2020-01-19 19:51:44 +00:00
args = get_args()
run_tasks()
if args.interval:
while True:
run_tasks()
time.sleep(args.interval)
2020-01-08 21:05:58 +00:00
if __name__ == "__main__":
main()