From 57ec262f7d2e0ba7b7e8f35215efab0c79a74c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sun, 5 Jul 2020 21:45:53 -0400 Subject: [PATCH] Add the ability to quit gracefgully if no longer tracking time --- pomodoroprompt.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pomodoroprompt.py b/pomodoroprompt.py index ad307be..c0fb640 100644 --- a/pomodoroprompt.py +++ b/pomodoroprompt.py @@ -24,6 +24,22 @@ def pomodoro_prompt_report(whatnext): whatdid = '' return whatdid +def quit_prompt(): + print('\nPress p to start a new pomodoro, q to quit') + choice = input('p/q: ').strip() + if choice.lower() in ('p', 'pomodoro'): + return + elif choice.lower() in ('q', 'quit', 'exit'): + quit() + else: + quit_prompt() + +def log_step(text): + # timelog.touch(exist_ok=True) + # with timelog.open('r+') as f: + # pp = PomodoroPrompt(timelog=f) + return + def record_task(whatdid, start, end=None): if end is None: end = datetime.now(pytz.utc) @@ -55,15 +71,13 @@ def main(): if choice.lower() in ('y', 'yes', ''): whatdid = pomodoro_prompt_report(whatnext) record_task(whatdid, start) + else: + quit_prompt() else: print('What did you break?') # If we somehow end up here, try a last-ditch effort to save. record_task('Incomplete, interrupted task:' + whatnext, start) - # timelog.touch(exist_ok=True) - # with timelog.open('r+') as f: - # pp = PomodoroPrompt(timelog=f) - if __name__ == '__main__': main()