From: Tomas Babej Date: Tue, 7 Apr 2015 19:46:41 +0000 (+0200) Subject: Task: Do not allow starting a Task which has already been started X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/b1f2be4453e6c58f751cfcd58459c28fc7fe6efc?hp=-c Task: Do not allow starting a Task which has already been started --- b1f2be4453e6c58f751cfcd58459c28fc7fe6efc diff --git a/tasklib/task.py b/tasklib/task.py index 1121988..9af111b 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -421,6 +421,12 @@ class Task(TaskResource): """ pass + class ActiveTask(Exception): + """ + Raised when the operation cannot be performed on the active task. + """ + pass + class InactiveTask(Exception): """ Raised when the operation cannot be performed on an inactive task. @@ -600,6 +606,8 @@ class Task(TaskResource): raise Task.CompletedTask("Cannot start a completed task") elif self.deleted: raise Task.DeletedTask("Deleted task cannot be started") + elif self.active: + raise Task.ActiveTask("Task is already active") self.warrior.execute_command([self['uuid'], 'start'])