mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Code Cleanup - undo
- Improved description of most recent change. - Added timestamp of most recent change.
This commit is contained in:
parent
e7ba2ab76d
commit
21c3a0ef48
2 changed files with 19 additions and 18 deletions
15
src/TDB.cpp
15
src/TDB.cpp
|
@ -528,22 +528,25 @@ void TDB::undo ()
|
||||||
u.pop_back ();
|
u.pop_back ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Date lastChange (::atoi (when.c_str ()));
|
||||||
|
std::cout << std::endl
|
||||||
|
<< "The last modification was made "
|
||||||
|
<< lastChange.toString ()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
// confirm
|
// confirm
|
||||||
if (prior != "")
|
if (prior != "")
|
||||||
{
|
{
|
||||||
Task priorTask (prior);
|
Task priorTask (prior);
|
||||||
Task currentTask (current);
|
Task currentTask (current);
|
||||||
std::cout << "The last modification was that "
|
std::cout << taskDifferences (prior, current)
|
||||||
<< taskDifferences (prior, current)
|
|
||||||
<< std::endl
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cout << "This was a new task."
|
std::cout << " - This was a new task"
|
||||||
<< std::endl
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
if (!confirm ("The undo command is irreversible. Are you sure you want to undo the last update?"))
|
if (!confirm ("The undo command is not reversible. Are you sure you want to undo the last update?"))
|
||||||
throw std::string ("No changes made.");
|
throw std::string ("No changes made.");
|
||||||
|
|
||||||
// Extract identifying uuid.
|
// Extract identifying uuid.
|
||||||
|
|
22
src/util.cpp
22
src/util.cpp
|
@ -498,35 +498,33 @@ std::string taskDifferences (const Task& before, const Task& after)
|
||||||
// Now start generating a description of the differences.
|
// Now start generating a description of the differences.
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
foreach (name, beforeOnly)
|
foreach (name, beforeOnly)
|
||||||
out << *name
|
out << " - "
|
||||||
<< " was deleted. ";
|
<< *name
|
||||||
|
<< " was deleted\n";
|
||||||
|
|
||||||
foreach (name, afterOnly)
|
foreach (name, afterOnly)
|
||||||
out << *name
|
out << " - "
|
||||||
|
<< *name
|
||||||
<< " was set to '"
|
<< " was set to '"
|
||||||
<< after.get (*name)
|
<< after.get (*name)
|
||||||
<< "'. ";
|
<< "'\n";
|
||||||
|
|
||||||
foreach (name, beforeAtts)
|
foreach (name, beforeAtts)
|
||||||
if (*name != "uuid" &&
|
if (*name != "uuid" &&
|
||||||
after.get (*name) != "" &&
|
after.get (*name) != "" &&
|
||||||
before.get (*name) != after.get (*name))
|
before.get (*name) != after.get (*name))
|
||||||
out << *name
|
out << " - "
|
||||||
|
<< *name
|
||||||
<< " was changed from '"
|
<< " was changed from '"
|
||||||
<< before.get (*name)
|
<< before.get (*name)
|
||||||
<< "' to '"
|
<< "' to '"
|
||||||
<< after.get (*name)
|
<< after.get (*name)
|
||||||
<< "'. ";
|
<< "'\n";
|
||||||
|
|
||||||
// Can't just say nothing.
|
// Can't just say nothing.
|
||||||
if (out.str ().length () == 0)
|
if (out.str ().length () == 0)
|
||||||
out << "No changes were made. ";
|
out << " - No changes were made\n";
|
||||||
|
|
||||||
/*
|
|
||||||
std::stringstream decorated;
|
|
||||||
decorated << "Task " << before.id << " was modified. " << out.str ();
|
|
||||||
return decorated.str ();
|
|
||||||
*/
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue