mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - undo
- Removed obsolete undelete command. - Removed obsolete undo command. - Implemented new undo command as a call to the stubbed TDB::undo call.
This commit is contained in:
parent
dc2bac1b5e
commit
af7803ea27
6 changed files with 14 additions and 112 deletions
102
src/command.cpp
102
src/command.cpp
|
@ -206,107 +206,9 @@ std::string handleTags ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// If a task is deleted, but is still in the pending file, then it may be
|
||||
// undeleted simply by changing it's status.
|
||||
std::string handleUndelete ()
|
||||
void handleUndo ()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.get ("locking", true));
|
||||
context.tdb.loadPending (tasks, context.filter);
|
||||
|
||||
// Filter sequence.
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
if (task->getStatus () == Task::deleted)
|
||||
{
|
||||
if (task->has ("recur"))
|
||||
out << "Task does not support 'undelete' for recurring tasks.\n";
|
||||
|
||||
task->setStatus (Task::pending);
|
||||
task->remove ("end");
|
||||
context.tdb.update (*task);
|
||||
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' successfully undeleted.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' is not deleted - therefore cannot be undeleted.\n";
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
out << "\n"
|
||||
<< "Please note that tasks can only be reliably undeleted if the undelete "
|
||||
<< "command is run immediately after the errant delete command."
|
||||
<< std::endl;
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// If a task is done, but is still in the pending file, then it may be undone
|
||||
// simply by changing it's status.
|
||||
std::string handleUndo ()
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.get ("locking", true));
|
||||
context.tdb.loadPending (tasks, context.filter);
|
||||
|
||||
// Filter sequence.
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
|
||||
foreach (task, tasks)
|
||||
{
|
||||
if (task->getStatus () == Task::completed)
|
||||
{
|
||||
if (task->has ("recur"))
|
||||
out << "Task does not support 'undo' for recurring tasks.\n";
|
||||
|
||||
task->setStatus (Task::pending);
|
||||
task->remove ("end");
|
||||
context.tdb.update (*task);
|
||||
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' successfully undone.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' is not completed - therefore cannot be undone.\n";
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
out << "\n"
|
||||
<< "Please note that tasks can only be reliably undone if the undo "
|
||||
<< "command is run immediately after the errant done command."
|
||||
<< std::endl;
|
||||
|
||||
return out.str ();
|
||||
context.tdb.undo ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue