mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Patch - Support tag exclusion filtering
- Now supports "-tag" in filters to filter out tasks that do not have the specified tag (thanks to Chris Pride). - Added unit tests to prevent regression. - Updated the filter docs to include examples.
This commit is contained in:
parent
0fcaf85652
commit
7aace1b3db
5 changed files with 55 additions and 4 deletions
|
@ -108,6 +108,9 @@ void filter (std::vector<T>& all, T& task)
|
|||
std::vector <std::string> tagList;
|
||||
task.getTags (tagList);
|
||||
|
||||
std::vector <std::string> removeTagList;
|
||||
task.getRemoveTags (removeTagList);
|
||||
|
||||
// Get all the attributes to match against.
|
||||
std::map <std::string, std::string> attrList;
|
||||
task.getAttributes (attrList);
|
||||
|
@ -180,7 +183,15 @@ void filter (std::vector<T>& all, T& task)
|
|||
++matches;
|
||||
|
||||
if (matches == tagList.size ())
|
||||
filtered.push_back (refTask);
|
||||
{
|
||||
matches = 0;
|
||||
for (unsigned int t = 0; t < removeTagList.size (); ++t)
|
||||
if (refTask.hasTag (removeTagList[t]))
|
||||
++matches;
|
||||
|
||||
if (matches == 0)
|
||||
filtered.push_back (refTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue