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

Show which todo IDs are incorrect for 'pri'.

parent 43163f4f
......@@ -31,17 +31,27 @@ class PriorityCommand(Command):
if not super(PriorityCommand, self).execute():
return False
numbers = None
priority = None
todos = []
invalid_numbers = []
for number in self.args[:-1]:
try:
numbers = self.args[:-1]
priority = self.args[-1]
todos.append(self.todolist.todo(number))
except InvalidTodoException:
invalid_numbers.append(number)
if len(invalid_numbers) > 1 or len(invalid_numbers) > 0 and len(todos) > 0:
for number in invalid_numbers:
self.error("Invalid todo number given: {}.".format(number))
elif len(invalid_numbers) == 1 and len(todos) == 0:
self.error("Invalid todo number given.")
else:
try:
priority = self.args[-1]
self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
if len(numbers) > 0:
todos = [self.todolist.todo(number) for number in numbers]
if len(todos) > 0:
if is_valid_priority(priority):
for todo in todos:
old_priority = todo.priority()
......@@ -60,11 +70,6 @@ class PriorityCommand(Command):
self.error(self.usage())
except (IndexError, InvalidCommandArgument):
self.error(self.usage())
except (InvalidTodoException):
if len(numbers) > 0 and priority:
self.error( "Invalid todo number given.")
else:
self.error(self.usage())
def usage(self):
return """Synopsis: pri <NUMBER1> [<NUMBER2> ...] <PRIORITY>"""
......
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