mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
dom: Added 'dom.tag.N' support
This commit is contained in:
parent
630df1a16a
commit
9d15a1aa84
1 changed files with 17 additions and 11 deletions
28
src/dom.cpp
28
src/dom.cpp
|
@ -99,17 +99,9 @@ bool domGet (
|
||||||
{
|
{
|
||||||
// Generate a unique, ordered list of tags.
|
// Generate a unique, ordered list of tags.
|
||||||
std::set <std::string> tags;
|
std::set <std::string> tags;
|
||||||
for (auto& line : database.allLines ())
|
for (auto& interval : getAllInclusions (database))
|
||||||
{
|
for (auto& tag : interval.tags ())
|
||||||
if (line[0] == 'i')
|
tags.insert (tag);
|
||||||
{
|
|
||||||
Interval interval;
|
|
||||||
interval.initialize (line);
|
|
||||||
|
|
||||||
for (auto& tag : interval.tags ())
|
|
||||||
tags.insert (tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// dom.tag.count
|
// dom.tag.count
|
||||||
if (pig.skipLiteral ("count"))
|
if (pig.skipLiteral ("count"))
|
||||||
|
@ -118,6 +110,20 @@ bool domGet (
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dom.tag.<N>
|
||||||
|
int n;
|
||||||
|
if (pig.getDigits (n))
|
||||||
|
{
|
||||||
|
if (n <= static_cast <int> (tags.size ()))
|
||||||
|
{
|
||||||
|
std::vector <std::string> all;
|
||||||
|
for (auto& tag : tags)
|
||||||
|
all.push_back (tag);
|
||||||
|
|
||||||
|
value = format ("{1}", all[n - 1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue