Commit 77abb6c0 authored by Jacek Sowiński's avatar Jacek Sowiński

Introduce 'before' and 'after' keywords to `dep ls`

From now on:
`topydo dep ls before 1` gives the same output as `topydo dep ls 1 to`
and:
`topydo dep ls after 1` gives the same output as `topydo dep ls to 1`
parent edc11eeb
...@@ -271,6 +271,42 @@ class DepCommandTest(CommandTest): ...@@ -271,6 +271,42 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n") self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls5(self): def test_ls5(self):
command = DepCommand(["ls", "before", "1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 2| Bar p:1\n| 3| Baz p:1\n")
self.assertEqual(self.errors, "")
def test_ls6(self):
command = DepCommand(["ls", "before", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "")
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls7(self):
command = DepCommand(["ls", "after", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "| 1| Foo id:1\n")
self.assertEqual(self.errors, "")
def test_ls8(self):
command = DepCommand(["ls", "after", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.dirty)
self.assertEqual(self.output, "")
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls9(self):
command = DepCommand(["ls", "1"], self.todolist, self.out, self.error) command = DepCommand(["ls", "1"], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -278,7 +314,7 @@ class DepCommandTest(CommandTest): ...@@ -278,7 +314,7 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.output, "") self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_ls6(self): def test_ls10(self):
command = DepCommand(["ls"], self.todolist, self.out, self.error) command = DepCommand(["ls"], self.todolist, self.out, self.error)
command.execute() command.execute()
...@@ -286,7 +322,7 @@ class DepCommandTest(CommandTest): ...@@ -286,7 +322,7 @@ class DepCommandTest(CommandTest):
self.assertFalse(self.output) self.assertFalse(self.output)
self.assertEqual(self.errors, command.usage() + "\n") self.assertEqual(self.errors, command.usage() + "\n")
def test_ls7(self): def test_ls11(self):
command = DepCommand(["ls", "top", "99"], self.todolist, self.out, command = DepCommand(["ls", "top", "99"], self.todolist, self.out,
self.error) self.error)
command.execute() command.execute()
......
...@@ -108,13 +108,13 @@ class DepCommand(Command): ...@@ -108,13 +108,13 @@ class DepCommand(Command):
arg2 = self.argument(2) arg2 = self.argument(2)
todos = [] todos = []
if arg2 == 'to': if arg2 == 'to' or arg1 == 'before':
# dep ls 1 to ... # dep ls 1 to OR dep ls before 1
number = arg1 number = arg1 if arg2 == 'to' else arg2
todo = self.todolist.todo(number) todo = self.todolist.todo(number)
todos = self.todolist.children(todo) todos = self.todolist.children(todo)
elif arg1 == 'to': elif arg1 in {'to', 'after'}:
# dep ls ... to 1 # dep ls to 1 OR dep ls after 1
number = arg2 number = arg2
todo = self.todolist.todo(number) todo = self.todolist.todo(number)
todos = self.todolist.parents(todo) todos = self.todolist.parents(todo)
...@@ -176,6 +176,7 @@ class DepCommand(Command): ...@@ -176,6 +176,7 @@ class DepCommand(Command):
dep add <NUMBER> <before|partof|after|parents-of|children-of> <NUMBER> dep add <NUMBER> <before|partof|after|parents-of|children-of> <NUMBER>
dep ls <NUMBER> to dep ls <NUMBER> to
dep ls to <NUMBER> dep ls to <NUMBER>
dep ls <before|after> <NUMBER>
dep dot <NUMBER> dep dot <NUMBER>
dep clean""" dep clean"""
......
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