diff --git a/ChangeLog b/ChangeLog index a662e9d1..abd52dd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ (thanks to Thomas Lauf). - TI-64 Command 'stop' with date before current interval's start date causes segfault (thanks to Thomas Lauf). +- TI-65 The 'tags' command should support a filter - Fixed Python 3 support of the holiday/refresh script (thanks to Jelle van der Waa). - Added missing man page link diff --git a/NEWS b/NEWS index 78f1b232..6f248e95 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ New Features in 1.1.0 tag 'Home.Garden' as well as individual 'Home', 'Garden' tags. - Taskwarrior integration hook now stops the clock in more situations, such as deleting or waiting a task. + - The 'tags' command now suports filters. Features not implemented in 1.1.0 diff --git a/doc/man/timew.1.in b/doc/man/timew.1.in index 2b9ef02a..1001cac6 100644 --- a/doc/man/timew.1.in +++ b/doc/man/timew.1.in @@ -371,8 +371,9 @@ Note that you can tag multiple intervals, with multiple tags: See also 'summary', 'shorten', 'lengthen', 'untag'. .TP -.B timew tags -Displays all the tags that have been used. +.B timew tags [] [ ...] +Displays all the tags that have been used by default. When a filter is specified, +shows only the tags that were used during that time. .TP .B timew track [ ...] diff --git a/src/commands/CmdHelp.cpp b/src/commands/CmdHelp.cpp index ce10b442..7dc0a047 100644 --- a/src/commands/CmdHelp.cpp +++ b/src/commands/CmdHelp.cpp @@ -61,7 +61,7 @@ int CmdHelpUsage (const Extensions& extensions) << " timew stop [ ...]\n" << " timew summary [] [ ...]\n" << " timew tag @ [@ ...] [ ...]\n" - << " timew tags\n" + << " timew tags [] [ ...]\n" << " timew track [ ...]\n" << " timew untag @ [@ ...] [ ...]\n" << " timew week [] [ ...]\n" @@ -849,9 +849,10 @@ int CmdHelp ( // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 else if (words[0] == "tags") std::cout << '\n' - << "Syntax: timew tags\n" + << "Syntax: timew tags [] [ ...]\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 diff --git a/src/commands/CmdTags.cpp b/src/commands/CmdTags.cpp index a0fa5e22..ab572fe3 100644 --- a/src/commands/CmdTags.cpp +++ b/src/commands/CmdTags.cpp @@ -33,21 +33,19 @@ #include //////////////////////////////////////////////////////////////////////////////// -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 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 ()) diff --git a/src/commands/commands.h b/src/commands/commands.h index f7a3699a..59af2d78 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -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& ); diff --git a/src/init.cpp b/src/init.cpp index 0f99892f..ba39bea9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -292,7 +292,7 @@ int dispatchCommand ( else if (command == "stop") status = CmdStop (cli, rules, database ); else if (command == "summary") status = CmdSummary (cli, rules, database ); else if (command == "tag") status = CmdTag (cli, rules, database ); - else if (command == "tags") status = CmdTags ( rules, database ); + else if (command == "tags") status = CmdTags (cli, rules, database ); else if (command == "track") status = CmdTrack (cli, rules, database ); else if (command == "untag") status = CmdUntag (cli, rules, database ); else if (command == "week") status = CmdChartWeek (cli, rules, database );