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):
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, "")
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):
command = AddCommand.AddCommand(["help"], self.todolist, self.out, self.error)
command.execute()
......
......@@ -7,6 +7,9 @@ default_command = ls
colors = 1
identifiers = linenumber ; or: text
[add]
auto_creation_date = 1
[ls]
hide_tags = id,p,ical
indent = 0
......
......@@ -47,7 +47,6 @@ class AddCommand(Command):
self.args = args
def get_todos_from_file(self):
if self.from_file == '-':
f = stdin
......@@ -107,7 +106,8 @@ class AddCommand(Command):
add_dependencies('before')
add_dependencies('after')
p_todo.set_creation_date(date.today())
if config().auto_creation_date():
p_todo.set_creation_date(date.today())
todo_text = _preprocess_input_todo(p_todo_text)
todo = self.todolist.add(todo_text)
......
......@@ -38,7 +38,15 @@ class _Config:
(such as todo.txt location passed with -t). The key is a tuple of
(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 = {
# topydo
......@@ -48,6 +56,9 @@ class _Config:
'archive_filename' : 'done.txt',
'identifiers': 'linenumber',
# add
'auto_creation_date': '1',
# ls
'hide_tags': 'id,p,ical',
'indent': 0,
......@@ -233,6 +244,12 @@ class _Config:
except ValueError:
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):
"""
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