- 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:
Paul Beckingham 2008-07-05 02:02:10 -04:00
parent 72c7afe1a1
commit 6c7ad2b398
6 changed files with 28 additions and 6 deletions

View file

@ -239,7 +239,6 @@ bool TDB::completeT (const T& t) const
bool TDB::addT (const T& t) const
{
T task (t);
std::vector <std::string> 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 writeCompleted (task);

View file

@ -381,10 +381,8 @@ void parse (
std::string value = arg.substr (colon + 1, std::string::npos);
if (validAttribute (name, value, conf))
{
if (name != "recur" || validDuration (value))
task.setAttribute (name, value);
}
}
// 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))
task.setDescription (descCandidate);
}

View file

@ -83,7 +83,7 @@ void initializeColorRules (Config& conf)
void autoColorize (T& task, Text::color& fg, Text::color& bg)
{
// 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.
if (gsFg["color.tagged"] != Text::nocolor ||

View file

@ -403,6 +403,9 @@ void handleAdd (const TDB& tdb, T& task, Config& conf)
sprintf (entryTime, "%u", (unsigned int) time (NULL));
task.setAttribute ("entry", entryTime);
if (task.getAttribute ("recur") != "")
decorateRecurringTask (task);
if (task.getDescription () == "")
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".
}
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -87,6 +87,7 @@ void handleModify (const TDB&, T&, Config&);
void handleColor (Config&);
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&);
void nag (const TDB&, T&, Config&);
void decorateRecurringTask (T&);
// util.cpp
bool confirm (const std::string&);

View file

@ -282,7 +282,7 @@ int convertDuration (const std::string& input)
else
{
// 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)
{
if (! isdigit (input[i]) &&