Commit 9d33afef authored by Bram Schoenmakers's avatar Bram Schoenmakers

Fix infinite loop with keep_sorted = 1.

When a subcommand finishes, _post_excecute() is called for sorting,
archiving and writing the file. But sorting is also a subcommand, which
in turn also calls _post_execute(), etc, etc.

So let the caller of _execute() decide when to call _post_execute.

This fixes issue #46.
parent 1176abbf
......@@ -55,6 +55,8 @@ class CLIApplication(CLIApplicationBase):
if self._execute(subcommand, args) == False:
sys.exit(1)
else:
self._post_execute()
def main():
""" Main entry point of the CLI. """
......
......@@ -193,12 +193,16 @@ class CLIApplicationBase(object):
self._input())
if command.execute() != False:
self._post_execute()
return True
return False
def _post_execute(self):
"""
Should be called when executing the user requested command has been
completed. It will do some maintenance and write out the final result
to the todo.txt file.
"""
if self.todolist.is_dirty():
self._archive()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment