From 7b0a1d0f16cace8b3f5e9d0e9402b8eb25647286 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 19 Jan 2020 19:51:44 +0000 Subject: [PATCH] Allow running script with interval --- todoist_github/cli.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/todoist_github/cli.py b/todoist_github/cli.py index a57c482..9e4cf16 100755 --- a/todoist_github/cli.py +++ b/todoist_github/cli.py @@ -1,13 +1,31 @@ #!/usr/bin/env python3 +import argparse +import time + from .tasks import ALL_TASKS -def main(): +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: print("Executing", task.__name__) task() +def main(): + args = get_args() + run_tasks() + if args.interval: + while True: + run_tasks() + time.sleep(args.interval) + + if __name__ == "__main__": main()