mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Reduce the number of project change messages when annoting and denoting.
This commit is contained in:
parent
1668aef66b
commit
75822eed47
2 changed files with 20 additions and 2 deletions
|
@ -67,6 +67,9 @@ int CmdAnnotate::execute (std::string& output)
|
|||
if (!modifications.size ())
|
||||
throw std::string (STRING_CMD_MODIFY_NEED_TEXT);
|
||||
|
||||
// Accumulated project change notifications.
|
||||
std::map <std::string, std::string> projectChanges;
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
|
@ -85,7 +88,7 @@ int CmdAnnotate::execute (std::string& output)
|
|||
++count;
|
||||
feedback_affected (STRING_CMD_ANNO_TASK, *task);
|
||||
if (context.verbose ("project"))
|
||||
context.footnote (onProjectChange (*task, false));
|
||||
projectChanges[task->get ("project")] = onProjectChange (*task, false);
|
||||
|
||||
// Annotate siblings.
|
||||
if (task->has ("parent"))
|
||||
|
@ -118,6 +121,12 @@ int CmdAnnotate::execute (std::string& output)
|
|||
}
|
||||
}
|
||||
|
||||
// Now list the project changes.
|
||||
std::map <std::string, std::string>::iterator i;
|
||||
for (i = projectChanges.begin (); i != projectChanges.end (); ++i)
|
||||
if (i->first != "")
|
||||
context.footnote (i->second);
|
||||
|
||||
context.tdb2.commit ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_ANNO_1 : STRING_CMD_ANNO_N, count);
|
||||
return rc;
|
||||
|
|
|
@ -68,6 +68,9 @@ int CmdDenotate::execute (std::string& output)
|
|||
if (!words.size ())
|
||||
throw std::string (STRING_CMD_DENO_WORDS);
|
||||
|
||||
// Accumulated project change notifications.
|
||||
std::map <std::string, std::string> projectChanges;
|
||||
|
||||
std::string pattern = words.combine ();
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
|
@ -122,7 +125,7 @@ int CmdDenotate::execute (std::string& output)
|
|||
context.tdb2.modify (*task);
|
||||
feedback_affected (format (STRING_CMD_DENO_FOUND, anno));
|
||||
if (context.verbose ("project"))
|
||||
context.footnote (onProjectChange (*task, false));
|
||||
projectChanges[task->get ("project")] = onProjectChange (*task, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -132,6 +135,12 @@ int CmdDenotate::execute (std::string& output)
|
|||
}
|
||||
}
|
||||
|
||||
// Now list the project changes.
|
||||
std::map <std::string, std::string>::iterator i;
|
||||
for (i = projectChanges.begin (); i != projectChanges.end (); ++i)
|
||||
if (i->first != "")
|
||||
context.footnote (i->second);
|
||||
|
||||
context.tdb2.commit ();
|
||||
feedback_affected (count == 1 ? STRING_CMD_DENO_1 : STRING_CMD_DENO_N, count);
|
||||
return rc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue