Commit 27ea752a authored by Bram Schoenmakers's avatar Bram Schoenmakers

Show usage instead of error message with tag command.

With the invocation `tag 1` it would print invalid todo number while
todo 1 does exist. It should print the usage text in that case.
parent acb21803
......@@ -195,6 +195,14 @@ class TagCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "| 4| Fnord\n")
self.assertEquals(self.errors, "")
def test_no_tag(self):
command = TagCommand(["4"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEquals(self.output, "")
self.assertEquals(self.errors, command.usage() + "\n")
def test_help(self):
command = TagCommand(["help"], self.todolist, self.out, self.error)
command.execute()
......
......@@ -51,8 +51,10 @@ class TagCommand(Command):
self.todo = self.todolist.todo(self.argument(0))
self.tag = self.argument(1)
self.current_values = self.todo.tag_values(self.tag)
except (InvalidCommandArgument, InvalidTodoException):
except InvalidTodoException:
self.error("Invalid todo number.")
except InvalidCommandArgument:
self.error(self.usage())
try:
self.value = self.argument(2)
......
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