TI-65: The 'tags' command should support a filter

This commit is contained in:
Paul Beckingham 2017-02-25 15:07:18 -05:00
parent d60af9bab2
commit 57bc4d71c8
7 changed files with 21 additions and 19 deletions

View file

@ -61,7 +61,7 @@ int CmdHelpUsage (const Extensions& extensions)
<< " timew stop [<tag> ...]\n"
<< " timew summary [<interval>] [<tag> ...]\n"
<< " timew tag @<id> [@<id> ...] <tag> [<tag> ...]\n"
<< " timew tags\n"
<< " timew tags [<interval>] [<tag> ...]\n"
<< " timew track <interval> [<tag> ...]\n"
<< " timew untag @<id> [@<id> ...] <tag> [<tag> ...]\n"
<< " timew week [<interval>] [<tag> ...]\n"
@ -849,9 +849,10 @@ int CmdHelp (
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
else if (words[0] == "tags")
std::cout << '\n'
<< "Syntax: timew tags\n"
<< "Syntax: timew tags [<interval>] [<tag> ...]\n"
<< '\n'
<< "Displays all the tags that have been used.\n"
<< "Displays all the tags that have been used by default. When a filter is specified,\n"
<< "shows only the tags that were used during that time.\n"
<< '\n';
// Ruler 1 2 3 4 5 6 7 8

View file

@ -33,21 +33,19 @@
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
int CmdTags (Rules& rules, Database& database)
int CmdTags (
const CLI& cli,
Rules& rules,
Database& database)
{
// Create a filter, with no default range.
auto filter = getFilter (cli);
// Generate a unique, ordered list of tags.
std::set <std::string> tags;
for (auto& line : database.allLines ())
{
if (line[0] == 'i')
{
Interval interval;
interval.initialize (line);
for (auto& tag : interval.tags ())
tags.insert (tag);
}
}
for (const auto& interval : getTracked (database, rules, filter))
for (auto& tag : interval.tags ())
tags.insert (tag);
// Shows all tags.
if (tags.size ())

View file

@ -56,7 +56,7 @@ int CmdSplit (const CLI&, Rules&, Database& );
int CmdStart (const CLI&, Rules&, Database& );
int CmdStop (const CLI&, Rules&, Database& );
int CmdTag (const CLI&, Rules&, Database& );
int CmdTags ( Rules&, Database& );
int CmdTags (const CLI&, Rules&, Database& );
int CmdTrack (const CLI&, Rules&, Database& );
int CmdUntag (const CLI&, Rules&, Database& );