mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
- Added error checking for "recur" without "due"
- Added error checking for "until" without "recur" - Added status setting for "task add" regarding T::recurring
This commit is contained in:
parent
72c7afe1a1
commit
6c7ad2b398
6 changed files with 28 additions and 6 deletions
|
@ -239,7 +239,6 @@ bool TDB::completeT (const T& t) const
|
||||||
bool TDB::addT (const T& t) const
|
bool TDB::addT (const T& t) const
|
||||||
{
|
{
|
||||||
T task (t);
|
T task (t);
|
||||||
|
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
task.getTags (tags);
|
task.getTags (tags);
|
||||||
|
|
||||||
|
@ -254,7 +253,8 @@ bool TDB::addT (const T& t) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task.getStatus () == T::pending)
|
if (task.getStatus () == T::pending ||
|
||||||
|
task.getStatus () == T::recurring)
|
||||||
return writePending (task);
|
return writePending (task);
|
||||||
|
|
||||||
return writeCompleted (task);
|
return writeCompleted (task);
|
||||||
|
|
|
@ -381,10 +381,8 @@ void parse (
|
||||||
std::string value = arg.substr (colon + 1, std::string::npos);
|
std::string value = arg.substr (colon + 1, std::string::npos);
|
||||||
|
|
||||||
if (validAttribute (name, value, conf))
|
if (validAttribute (name, value, conf))
|
||||||
{
|
|
||||||
if (name != "recur" || validDuration (value))
|
if (name != "recur" || validDuration (value))
|
||||||
task.setAttribute (name, value);
|
task.setAttribute (name, value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substitution of description text.
|
// Substitution of description text.
|
||||||
|
@ -408,6 +406,14 @@ void parse (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (task.getAttribute ("recur") != "" &&
|
||||||
|
task.getAttribute ("due") == "")
|
||||||
|
throw std::string ("You cannot specify a recurring task without a due date.");
|
||||||
|
|
||||||
|
if (task.getAttribute ("until") != "" &&
|
||||||
|
task.getAttribute ("recur") == "")
|
||||||
|
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
||||||
|
|
||||||
if (validDescription (descCandidate))
|
if (validDescription (descCandidate))
|
||||||
task.setDescription (descCandidate);
|
task.setDescription (descCandidate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ void initializeColorRules (Config& conf)
|
||||||
void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
void autoColorize (T& task, Text::color& fg, Text::color& bg)
|
||||||
{
|
{
|
||||||
// Note: fg, bg already contain colors specifically assigned via command.
|
// Note: fg, bg already contain colors specifically assigned via command.
|
||||||
// TODO These rules form a hierarchy - the last rule is king.
|
// Note: These rules form a hierarchy - the last rule is king.
|
||||||
|
|
||||||
// Colorization of the tagged.
|
// Colorization of the tagged.
|
||||||
if (gsFg["color.tagged"] != Text::nocolor ||
|
if (gsFg["color.tagged"] != Text::nocolor ||
|
||||||
|
|
15
src/task.cpp
15
src/task.cpp
|
@ -403,6 +403,9 @@ void handleAdd (const TDB& tdb, T& task, Config& conf)
|
||||||
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
||||||
task.setAttribute ("entry", entryTime);
|
task.setAttribute ("entry", entryTime);
|
||||||
|
|
||||||
|
if (task.getAttribute ("recur") != "")
|
||||||
|
decorateRecurringTask (task);
|
||||||
|
|
||||||
if (task.getDescription () == "")
|
if (task.getDescription () == "")
|
||||||
throw std::string ("Cannot add a blank task.");
|
throw std::string ("Cannot add a blank task.");
|
||||||
|
|
||||||
|
@ -3356,3 +3359,15 @@ void nag (const TDB& tdb, T& task, Config& conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void decorateRecurringTask (T& task)
|
||||||
|
{
|
||||||
|
if (task.getAttribute ("due") != "" &&
|
||||||
|
task.getAttribute ("recur") != "")
|
||||||
|
{
|
||||||
|
task.setAttribute ("base", task.getAttribute ("due"));
|
||||||
|
|
||||||
|
// TODO Create "range".
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -87,6 +87,7 @@ void handleModify (const TDB&, T&, Config&);
|
||||||
void handleColor (Config&);
|
void handleColor (Config&);
|
||||||
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&);
|
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&);
|
||||||
void nag (const TDB&, T&, Config&);
|
void nag (const TDB&, T&, Config&);
|
||||||
|
void decorateRecurringTask (T&);
|
||||||
|
|
||||||
// util.cpp
|
// util.cpp
|
||||||
bool confirm (const std::string&);
|
bool confirm (const std::string&);
|
||||||
|
|
|
@ -282,7 +282,7 @@ int convertDuration (const std::string& input)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Verify all digits followed by d, w, m, q, or y.
|
// Verify all digits followed by d, w, m, q, or y.
|
||||||
int length = input.length ();
|
unsigned int length = input.length ();
|
||||||
for (unsigned int i = 0; i < length; ++i)
|
for (unsigned int i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
if (! isdigit (input[i]) &&
|
if (! isdigit (input[i]) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue