mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TW-1881: default.scheduled seems not to work
- Thanks to Onion.
This commit is contained in:
parent
1b40c802c2
commit
eb935d895b
9 changed files with 42 additions and 6 deletions
|
@ -49,6 +49,8 @@
|
||||||
(thanks to Eli).
|
(thanks to Eli).
|
||||||
- TW-1878 uuids subcommand produces a space-delimited list, not comma-delimited
|
- TW-1878 uuids subcommand produces a space-delimited list, not comma-delimited
|
||||||
(thanks to Scott Kostyshak).
|
(thanks to Scott Kostyshak).
|
||||||
|
- TW-1881 default.scheduled seems not to work
|
||||||
|
(thanks to Onion).
|
||||||
- Added 'juhannus' as a synonym for 'midsommarafton'
|
- Added 'juhannus' as a synonym for 'midsommarafton'
|
||||||
(thanks to Lynoure Braakman).
|
(thanks to Lynoure Braakman).
|
||||||
- Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY'
|
- Deprecated the 'DUETODAY' virtual tag, which is a synonym for the 'TODAY'
|
||||||
|
|
|
@ -1183,6 +1183,14 @@ Provides a default due date for the
|
||||||
command, if you don't specify one. You can use a date, or a duration value which
|
command, if you don't specify one. You can use a date, or a duration value which
|
||||||
is assumed to be relative to 'now'. The default is blank.
|
is assumed to be relative to 'now'. The default is blank.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
default.scheduled=...
|
||||||
|
Provides a default scheduled date for the
|
||||||
|
.I task add
|
||||||
|
command, if you don't specify one. You can use a date, or a duration value which
|
||||||
|
is assumed to be relative to 'now'. The default is blank.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
uda.<name>.default=...
|
uda.<name>.default=...
|
||||||
|
|
|
@ -102,6 +102,7 @@ syn match taskrcGoodKey '^\s*\Vdefault.command='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdefault.due='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdefault.due='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdefault.priority='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdefault.priority='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdefault.project='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdefault.project='he=e-1
|
||||||
|
syn match taskrcGoodKey '^\s*\Vdefault.scheduled='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdefaultheight='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdefaultheight='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdefaultwidth='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdefaultwidth='he=e-1
|
||||||
syn match taskrcGoodKey '^\s*\Vdependency.confirmation='he=e-1
|
syn match taskrcGoodKey '^\s*\Vdependency.confirmation='he=e-1
|
||||||
|
|
|
@ -249,6 +249,7 @@ std::string Config::_defaults =
|
||||||
"\n"
|
"\n"
|
||||||
"#default.project=foo # Default project for 'add' command\n"
|
"#default.project=foo # Default project for 'add' command\n"
|
||||||
"#default.due=eom # Default due date for 'add' command\n"
|
"#default.due=eom # Default due date for 'add' command\n"
|
||||||
|
"#default.scheduled=eom # Default scheduled date for 'add' command\n"
|
||||||
"default.command=next # When no arguments are specified\n"
|
"default.command=next # When no arguments are specified\n"
|
||||||
"\n"
|
"\n"
|
||||||
"_forcecolor=0 # Forces color to be on, even for non TTY output\n"
|
"_forcecolor=0 # Forces color to be on, even for non TTY output\n"
|
||||||
|
|
|
@ -686,6 +686,7 @@ void Context::staticInitialization ()
|
||||||
|
|
||||||
Task::defaultProject = config.get ("default.project");
|
Task::defaultProject = config.get ("default.project");
|
||||||
Task::defaultDue = config.get ("default.due");
|
Task::defaultDue = config.get ("default.due");
|
||||||
|
Task::defaultScheduled = config.get ("default.scheduled");
|
||||||
|
|
||||||
Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||||
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||||
|
|
28
src/Task.cpp
28
src/Task.cpp
|
@ -67,10 +67,11 @@ extern Task& contextTask;
|
||||||
static const float epsilon = 0.000001;
|
static const float epsilon = 0.000001;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string Task::defaultProject = "";
|
std::string Task::defaultProject = "";
|
||||||
std::string Task::defaultDue = "";
|
std::string Task::defaultDue = "";
|
||||||
bool Task::searchCaseSensitive = true;
|
std::string Task::defaultScheduled = "";
|
||||||
bool Task::regex = false;
|
bool Task::searchCaseSensitive = true;
|
||||||
|
bool Task::regex = false;
|
||||||
std::map <std::string, std::string> Task::attributes;
|
std::map <std::string, std::string> Task::attributes;
|
||||||
|
|
||||||
std::map <std::string, float> Task::coefficients;
|
std::map <std::string, float> Task::coefficients;
|
||||||
|
@ -1567,6 +1568,20 @@ void Task::validate (bool applyDefault /* = true */)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override with default.scheduled, if not specified.
|
||||||
|
if (Task::defaultScheduled != "" &&
|
||||||
|
! has ("scheduled"))
|
||||||
|
{
|
||||||
|
if (context.columns["scheduled"]->validate (Task::defaultScheduled))
|
||||||
|
{
|
||||||
|
Duration dur (Task::defaultScheduled);
|
||||||
|
if (dur.toTime_t () != 0)
|
||||||
|
set ("scheduled", (Datetime () + dur.toTime_t ()).toEpoch ());
|
||||||
|
else
|
||||||
|
set ("scheduled", Datetime (Task::defaultScheduled).toEpoch ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If a UDA has a default value in the configuration,
|
// If a UDA has a default value in the configuration,
|
||||||
// override with uda.(uda).default, if not specified.
|
// override with uda.(uda).default, if not specified.
|
||||||
// Gather a list of all UDAs with a .default value
|
// Gather a list of all UDAs with a .default value
|
||||||
|
@ -2046,8 +2061,9 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
// ::composeF4 will skip if the value is blank, but the presence of
|
// ::composeF4 will skip if the value is blank, but the presence of
|
||||||
// the attribute will prevent ::validate from applying defaults.
|
// the attribute will prevent ::validate from applying defaults.
|
||||||
if ((has (name) && get (name) != "") ||
|
if ((has (name) && get (name) != "") ||
|
||||||
(name == "due" && context.config.has ("default.due")) ||
|
(name == "due" && context.config.has ("default.due")) ||
|
||||||
(name == "project" && context.config.has ("default.project")))
|
(name == "scheduled" && context.config.has ("default.scheduled")) ||
|
||||||
|
(name == "project" && context.config.has ("default.project")))
|
||||||
{
|
{
|
||||||
mods = true;
|
mods = true;
|
||||||
set (name, "");
|
set (name, "");
|
||||||
|
|
|
@ -39,6 +39,7 @@ class Task
|
||||||
public:
|
public:
|
||||||
static std::string defaultProject;
|
static std::string defaultProject;
|
||||||
static std::string defaultDue;
|
static std::string defaultDue;
|
||||||
|
static std::string defaultScheduled;
|
||||||
static bool searchCaseSensitive;
|
static bool searchCaseSensitive;
|
||||||
static bool regex;
|
static bool regex;
|
||||||
static std::map <std::string, std::string> attributes; // name -> type
|
static std::map <std::string, std::string> attributes; // name -> type
|
||||||
|
|
|
@ -144,6 +144,7 @@ int CmdShow::execute (std::string& output)
|
||||||
" default.command"
|
" default.command"
|
||||||
" default.due"
|
" default.due"
|
||||||
" default.project"
|
" default.project"
|
||||||
|
" default.scheduled"
|
||||||
" defaultheight"
|
" defaultheight"
|
||||||
" defaultwidth"
|
" defaultwidth"
|
||||||
" dependency.confirmation"
|
" dependency.confirmation"
|
||||||
|
|
|
@ -64,6 +64,7 @@ class TestDefaults(TestCase):
|
||||||
cls.t.config("default.project", "PROJECT")
|
cls.t.config("default.project", "PROJECT")
|
||||||
cls.t.config("uda.priority.default", "M")
|
cls.t.config("uda.priority.default", "M")
|
||||||
cls.t.config("default.due", "eom")
|
cls.t.config("default.due", "eom")
|
||||||
|
cls.t.config("default.scheduled", "eom")
|
||||||
|
|
||||||
def test_all_defaults(self):
|
def test_all_defaults(self):
|
||||||
"""Verify all defaults are employed"""
|
"""Verify all defaults are employed"""
|
||||||
|
@ -73,6 +74,7 @@ class TestDefaults(TestCase):
|
||||||
self.assertIn('"project":"PROJECT"', out)
|
self.assertIn('"project":"PROJECT"', out)
|
||||||
self.assertIn('"priority":"M"', out)
|
self.assertIn('"priority":"M"', out)
|
||||||
self.assertIn('"due":"', out)
|
self.assertIn('"due":"', out)
|
||||||
|
self.assertIn('"scheduled":"', out)
|
||||||
|
|
||||||
def test_all_specified(self):
|
def test_all_specified(self):
|
||||||
self.t("add project:specific priority:L due:eoy all specified")
|
self.t("add project:specific priority:L due:eoy all specified")
|
||||||
|
@ -81,6 +83,7 @@ class TestDefaults(TestCase):
|
||||||
self.assertIn('"project":"specific"', out)
|
self.assertIn('"project":"specific"', out)
|
||||||
self.assertIn('"priority":"L"', out)
|
self.assertIn('"priority":"L"', out)
|
||||||
self.assertIn('"due":"', out)
|
self.assertIn('"due":"', out)
|
||||||
|
self.assertIn('"scheduled":"', out)
|
||||||
|
|
||||||
def test_project_specified(self):
|
def test_project_specified(self):
|
||||||
self.t("add project:specific project specified")
|
self.t("add project:specific project specified")
|
||||||
|
@ -89,6 +92,7 @@ class TestDefaults(TestCase):
|
||||||
self.assertIn('"project":"specific"', out)
|
self.assertIn('"project":"specific"', out)
|
||||||
self.assertIn('"priority":"M"', out)
|
self.assertIn('"priority":"M"', out)
|
||||||
self.assertIn('"due":"', out)
|
self.assertIn('"due":"', out)
|
||||||
|
self.assertIn('"scheduled":"', out)
|
||||||
|
|
||||||
def test_priority_specified(self):
|
def test_priority_specified(self):
|
||||||
self.t("add priority:L priority specified")
|
self.t("add priority:L priority specified")
|
||||||
|
@ -97,6 +101,7 @@ class TestDefaults(TestCase):
|
||||||
self.assertIn('"project":"PROJECT"', out)
|
self.assertIn('"project":"PROJECT"', out)
|
||||||
self.assertIn('"priority":"L"', out)
|
self.assertIn('"priority":"L"', out)
|
||||||
self.assertIn('"due":"', out)
|
self.assertIn('"due":"', out)
|
||||||
|
self.assertIn('"scheduled":"', out)
|
||||||
|
|
||||||
def test_default_command(self):
|
def test_default_command(self):
|
||||||
self.t("add foo")
|
self.t("add foo")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue