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
from DepCommand import DepCommand
import Config
from DoCommand import DoCommand
import Filter
from ListCommand import ListCommand
from PrettyPrinter import pretty_print
from PriorityCommand import PriorityCommand
import Sorter
import TodoFile
import TodoList
from Utils import convert_todo_number
......@@ -86,14 +85,8 @@ class Application(object): # TODO: rename to CLIApplication
command.execute()
def list(self):
sorter = Sorter.Sorter(Config.SORT_STRING)
filters = [Filter.DependencyFilter(self.todolist),
Filter.RelevanceFilter()]
if len(sys.argv) > 2:
filters.append(Filter.GrepFilter(sys.argv[2]))
print self.todolist.view(sorter, filters).pretty_print()
command = ListCommand(arguments(), self.todolist)
command.execute()
def run(self):
""" 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