Commit 62b77241 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add option to disable adding the creation date for 'add'.

Fixes #20.
parent d2eba233
...@@ -266,6 +266,16 @@ class AddCommandTest(CommandTest): ...@@ -266,6 +266,16 @@ class AddCommandTest(CommandTest):
self.assertEqual(self.output, u("| 1| {tod} Foo @fo\u00f3b\u0105r due:{tod} id:1\n| 2| {tod} Bar +baz t:{tod} p:1\n".format(tod=self.today))) self.assertEqual(self.output, u("| 1| {tod} Foo @fo\u00f3b\u0105r due:{tod} id:1\n| 2| {tod} Bar +baz t:{tod} p:1\n".format(tod=self.today)))
self.assertEqual(self.errors, "") self.assertEqual(self.errors, "")
def test_add_task_without_date(self):
config(p_overrides={('add', 'auto_creation_date'): '0'})
args = ["New todo"]
command = AddCommand.AddCommand(args, self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), "New todo")
self.assertEqual(self.errors, "")
def test_help(self): def test_help(self):
command = AddCommand.AddCommand(["help"], self.todolist, self.out, self.error) command = AddCommand.AddCommand(["help"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -7,6 +7,9 @@ default_command = ls ...@@ -7,6 +7,9 @@ default_command = ls
colors = 1 colors = 1
identifiers = linenumber ; or: text identifiers = linenumber ; or: text
[add]
auto_creation_date = 1
[ls] [ls]
hide_tags = id,p,ical hide_tags = id,p,ical
indent = 0 indent = 0
......
...@@ -47,7 +47,6 @@ class AddCommand(Command): ...@@ -47,7 +47,6 @@ class AddCommand(Command):
self.args = args self.args = args
def get_todos_from_file(self): def get_todos_from_file(self):
if self.from_file == '-': if self.from_file == '-':
f = stdin f = stdin
...@@ -107,6 +106,7 @@ class AddCommand(Command): ...@@ -107,6 +106,7 @@ class AddCommand(Command):
add_dependencies('before') add_dependencies('before')
add_dependencies('after') add_dependencies('after')
if config().auto_creation_date():
p_todo.set_creation_date(date.today()) p_todo.set_creation_date(date.today())
todo_text = _preprocess_input_todo(p_todo_text) todo_text = _preprocess_input_todo(p_todo_text)
......
...@@ -38,7 +38,15 @@ class _Config: ...@@ -38,7 +38,15 @@ class _Config:
(such as todo.txt location passed with -t). The key is a tuple of (such as todo.txt location passed with -t). The key is a tuple of
(section, option), the value is the option's value. (section, option), the value is the option's value.
""" """
self.sections = ['topydo', 'tags', 'sort', 'ls', 'dep', 'colorscheme'] self.sections = [
'add',
'colorscheme',
'dep',
'ls',
'sort',
'tags',
'topydo',
]
self.defaults = { self.defaults = {
# topydo # topydo
...@@ -48,6 +56,9 @@ class _Config: ...@@ -48,6 +56,9 @@ class _Config:
'archive_filename' : 'done.txt', 'archive_filename' : 'done.txt',
'identifiers': 'linenumber', 'identifiers': 'linenumber',
# add
'auto_creation_date': '1',
# ls # ls
'hide_tags': 'id,p,ical', 'hide_tags': 'id,p,ical',
'indent': 0, 'indent': 0,
...@@ -233,6 +244,12 @@ class _Config: ...@@ -233,6 +244,12 @@ class _Config:
except ValueError: except ValueError:
return int(self.defaults['link_color']) return int(self.defaults['link_color'])
def auto_creation_date(self):
try:
return self.cp.getboolean('add', 'auto_creation_date')
except ValueError:
return self.defaults['auto_creation_date'] == '1'
def config(p_path=None, p_overrides=None): def config(p_path=None, p_overrides=None):
""" """
Retrieve the config instance. Retrieve the config instance.
......
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