Commit 04638cb0 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add list command.

parent 738b1a04
import Command
import Config
import Filter
import Sorter
class ListCommand(Command.Command):
def __init__(self, p_args, p_todolist):
super(ListCommand, self).__init__(p_args, p_todolist)
def execute(self):
sorter = Sorter.Sorter(Config.SORT_STRING)
filters = [Filter.DependencyFilter(self.todolist),
Filter.RelevanceFilter()]
if len(self.args) > 0:
filters.append(Filter.GrepFilter(self.argument(0)))
print self.todolist.view(sorter, filters).pretty_print() # FIXME
return True
...@@ -8,10 +8,9 @@ from AppendCommand import AppendCommand ...@@ -8,10 +8,9 @@ from AppendCommand import AppendCommand
from DepCommand import DepCommand from DepCommand import DepCommand
import Config import Config
from DoCommand import DoCommand from DoCommand import DoCommand
import Filter from ListCommand import ListCommand
from PrettyPrinter import pretty_print from PrettyPrinter import pretty_print
from PriorityCommand import PriorityCommand from PriorityCommand import PriorityCommand
import Sorter
import TodoFile import TodoFile
import TodoList import TodoList
from Utils import convert_todo_number from Utils import convert_todo_number
...@@ -86,14 +85,8 @@ class Application(object): # TODO: rename to CLIApplication ...@@ -86,14 +85,8 @@ class Application(object): # TODO: rename to CLIApplication
command.execute() command.execute()
def list(self): def list(self):
sorter = Sorter.Sorter(Config.SORT_STRING) command = ListCommand(arguments(), self.todolist)
filters = [Filter.DependencyFilter(self.todolist), command.execute()
Filter.RelevanceFilter()]
if len(sys.argv) > 2:
filters.append(Filter.GrepFilter(sys.argv[2]))
print self.todolist.view(sorter, filters).pretty_print()
def run(self): def run(self):
""" Main entry function. """ """ Main entry function. """
......
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