mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- Implemented "task undo" to counteract "task do".
This commit is contained in:
parent
dc1760769f
commit
d265ac6c2d
6 changed files with 55 additions and 2 deletions
|
@ -7,7 +7,9 @@ represents a feature release, and the Z represents a patch.
|
|||
|
||||
------ current release ---------------------------
|
||||
|
||||
1.5.0 (?/?/?)
|
||||
1.5.0 (?/?/2008)
|
||||
+ "task undo" can now retract a "task done" command, provided no reports
|
||||
have been run (and therefore TDB::gc run)
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
|
|
|
@ -94,7 +94,8 @@
|
|||
|
||||
<h4>New in version 1.5.0 (?/?/?)</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<li>"task undo" can now retract a "task done" command, provided no
|
||||
reports have been run.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -203,6 +203,49 @@ void handleUndelete (TDB& tdb, T& task, Config& conf)
|
|||
<< "command is run immediately after the errant delete command." << std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// If a task is done, but is still in the pending file, then it may be undone
|
||||
// simply by changing it's status.
|
||||
void handleUndo (TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
std::vector <T> all;
|
||||
tdb.allPendingT (all);
|
||||
|
||||
int id = task.getId ();
|
||||
std::vector <T>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
{
|
||||
if (it->getId () == id)
|
||||
{
|
||||
if (it->getStatus () == T::completed)
|
||||
{
|
||||
if (it->getAttribute ("recur") != "")
|
||||
{
|
||||
std::cout << "Task does not support 'undo' for recurring tasks." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
T restored (*it);
|
||||
restored.setStatus (T::pending);
|
||||
restored.removeAttribute ("end");
|
||||
tdb.modifyT (restored);
|
||||
|
||||
std::cout << "Task " << id << " successfully undone." << std::endl;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Task " << id << " is not done - therefore cannot be undone." << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Task " << id
|
||||
<< " not found - tasks can only be reliably undone if the undo" << std::endl
|
||||
<< "command is run immediately after the errant done command." << std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void handleVersion (Config& conf)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,7 @@ static const char* commands[] =
|
|||
"summary",
|
||||
"tags",
|
||||
"undelete",
|
||||
"undo",
|
||||
"usage",
|
||||
"version",
|
||||
"",
|
||||
|
|
|
@ -125,6 +125,10 @@ static void shortUsage (Config& conf)
|
|||
table.addCell (row, 1, "task done ID");
|
||||
table.addCell (row, 2, "Marks the specified task as completed");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task undo ID");
|
||||
table.addCell (row, 2, "Marks the specified done task as pending, provided a report has not yet been run");
|
||||
|
||||
row = table.addRow ();
|
||||
table.addCell (row, 1, "task projects");
|
||||
table.addCell (row, 2, "Shows a list of all project names used, and how many tasks are in each");
|
||||
|
@ -316,6 +320,7 @@ int main (int argc, char** argv)
|
|||
else if (command == "delete") handleDelete (tdb, task, conf);
|
||||
else if (command == "start") handleStart (tdb, task, conf);
|
||||
else if (command == "done") handleDone (tdb, task, conf);
|
||||
else if (command == "undo") handleUndo (tdb, task, conf);
|
||||
else if (command == "export") handleExport (tdb, task, conf);
|
||||
else if (command == "version") handleVersion ( conf);
|
||||
else if (command == "summary") handleReportSummary (tdb, task, conf);
|
||||
|
|
|
@ -76,6 +76,7 @@ void handleExport (TDB&, T&, Config&);
|
|||
void handleDelete (TDB&, T&, Config&);
|
||||
void handleStart (TDB&, T&, Config&);
|
||||
void handleDone (TDB&, T&, Config&);
|
||||
void handleUndo (TDB&, T&, Config&);
|
||||
void handleModify (TDB&, T&, Config&);
|
||||
void handleColor (Config&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue