Commit b770db60 authored by Jacek Sowiński's avatar Jacek Sowiński

Use `depri` on multiple todo items at once

parent 2295ff51
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from topydo.lib.Command import Command, InvalidCommandArgument from topydo.lib.MultiCommand import MultiCommand
from topydo.lib.TodoListBase import InvalidTodoException from topydo.lib.PrettyPrinterFilter import PrettyPrinterNumbers
class DepriCommand(Command): class DepriCommand(MultiCommand):
def __init__(self, p_args, p_todolist, def __init__(self, p_args, p_todolist,
p_out=lambda a: None, p_out=lambda a: None,
p_err=lambda a: None, p_err=lambda a: None,
...@@ -25,28 +25,23 @@ class DepriCommand(Command): ...@@ -25,28 +25,23 @@ class DepriCommand(Command):
super(DepriCommand, self).__init__( super(DepriCommand, self).__init__(
p_args, p_todolist, p_out, p_err, p_prompt) p_args, p_todolist, p_out, p_err, p_prompt)
def execute(self): self.get_todos(self.args)
if not super(DepriCommand, self).execute():
return False
todo = None def execute_multi_specific(self):
try: try:
todo = self.todolist.todo(self.argument(0)) self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
if todo.priority() != None: for todo in self.todos:
self.todolist.set_priority(todo, None) if todo.priority() != None:
self.out("Priority removed.") self.todolist.set_priority(todo, None)
self.out(self.printer.print_todo(todo)) self.out("Priority removed.")
except InvalidCommandArgument: self.out(self.printer.print_todo(todo))
except IndexError:
self.error(self.usage()) self.error(self.usage())
except (InvalidTodoException):
if not todo:
self.error( "Invalid todo number given.")
else:
self.error(self.usage())
def usage(self): def usage(self):
return """Synopsis: depri <NUMBER>""" return """Synopsis: depri <NUMBER1> [<NUMBER2> ...]"""
def help(self): def help(self):
return """Removes the priority of the given todo item.""" return """Removes the priority of the given todo item(s)."""
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