Commit 91dcd57b authored by Bram Schoenmakers's avatar Bram Schoenmakers

Pass arguments to the command.

parent cb26e769
......@@ -6,9 +6,9 @@ import Command
from RelativeDate import relative_date_to_date
class AddCommand(Command.Command):
def __init__(self, p_text, p_todolist):
super(AddCommand, self).__init__(p_todolist)
self.text = p_text
def __init__(self, p_args, p_todolist):
super(AddCommand, self).__init__(p_args, p_todolist)
self.text = ' '.join(p_args)
def _preprocess_input_todo(self):
"""
......@@ -62,3 +62,5 @@ class AddCommand(Command.Command):
self.todo = self.todolist.add(self.text)
self._postprocess_input_todo()
return True
class Command(object):
def __init__(self, p_todolist):
def __init__(self, p_args, p_todolist):
self.args = p_args
self.todolist = p_todolist
def execute(self):
""" The command to execute. """
pass
return False
......@@ -39,6 +39,18 @@ def argument(p_number):
return value
def arguments():
"""
Retrieves all values from the argument list starting from the given
position.
"""
try:
values = sys.argv[2:] # strip off subcommand at position 1
except IndexError:
usage()
return values
def convert_number(p_number):
""" Converts a string number to an integer. """
try:
......@@ -60,10 +72,10 @@ class Application(object): # TODO: rename to CLIApplication
print printed[0]
def add(self):
command = AddCommand(argument(2), self.todolist)
command.execute()
self.print_todo(self.todolist.count())
self.dirty = True
command = AddCommand(arguments(), self.todolist)
if command.execute():
self.print_todo(self.todolist.count())
self.dirty = True
def append(self):
""" Appends a text to a todo item. """
......
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