Commit ca43307d authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add support for OrdinalTagFilter in ListCommand.

parent a736ccda
...@@ -137,6 +137,14 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -137,6 +137,14 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, " 1 (C) Foo @Context2 Not@Context +Project1 Not+Project\n 4 (C) Drink beer @ home\n 5 (C) 13 + 29 = 42\n 2 (D) Bar @Context1 +Project2 p:1\n") self.assertEquals(self.output, " 1 (C) Foo @Context2 Not@Context +Project1 Not+Project\n 4 (C) Drink beer @ home\n 5 (C) 13 + 29 = 42\n 2 (D) Bar @Context1 +Project2 p:1\n")
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list15(self):
command = ListCommand.ListCommand(["p:<10"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEquals(self.output, " 2 (D) Bar @Context1 +Project2 p:1\n")
self.assertEquals(self.errors, "")
def test_help(self): def test_help(self):
command = ListCommand.ListCommand(["help"], self.todolist, self.out, self.error) command = ListCommand.ListCommand(["help"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# 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/>.
import re
import Command import Command
from Config import config from Config import config
import Filter import Filter
...@@ -44,21 +46,26 @@ class ListCommand(Command.Command): ...@@ -44,21 +46,26 @@ class ListCommand(Command.Command):
def _filters(self): def _filters(self):
filters = [] filters = []
def grep_filters(): def arg_filters():
result = []
for arg in self.args: for arg in self.args:
if len(arg) > 1 and arg[0] == '-': if re.match(Filter.ORDINAL_TAG_MATCH, arg):
argfilter = Filter.OrdinalTagFilter(arg)
elif len(arg) > 1 and arg[0] == '-':
# when a word starts with -, exclude it # when a word starts with -, exclude it
grep = Filter.NegationFilter(Filter.GrepFilter(arg[1:])) argfilter = Filter.NegationFilter(Filter.GrepFilter(arg[1:]))
else: else:
grep = Filter.GrepFilter(arg) argfilter = Filter.GrepFilter(arg)
result.append(argfilter)
filters.append(grep) return result
if not self.show_all: if not self.show_all:
filters.append(Filter.DependencyFilter(self.todolist)) filters.append(Filter.DependencyFilter(self.todolist))
filters.append(Filter.RelevanceFilter()) filters.append(Filter.RelevanceFilter())
grep_filters() filters += arg_filters()
if not self.show_all: if not self.show_all:
filters.append(Filter.LimitFilter(config().list_limit())) filters.append(Filter.LimitFilter(config().list_limit()))
......
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