Virtual Tags: New 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags

- Added documentation.
This commit is contained in:
Paul Beckingham 2015-08-31 16:54:18 -04:00
parent ada6c24789
commit 4008a64fdd
6 changed files with 64 additions and 47 deletions

View file

@ -153,7 +153,7 @@
Shahaf).
- When multiple tasks are 'edit'ed, a failure causes the editing to stop (thanks
to Daniel Shahaf).
- New 'UDA' and 'ORPHAN' virtual tags.
- New 'UDA', 'ORPHAN', 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags.
- Commands that do not accept filters or modifications now generate an error
when extra arguments are specified.
- Improved zsh support (thanks to Daniel Shahaf).

2
NEWS
View file

@ -3,7 +3,7 @@ New Features in Taskwarrior 2.4.5
- The active context, if one is set, is now identified in "task context list"
- It is an error to attempt adding or removing a virtual tag.
- New 'UDA' and 'ORPHAN' virtual tags.
- New 'UDA', 'ORPHAN', 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags.
New commands in Taskwarrior 2.4.5

View file

@ -665,11 +665,14 @@ are:
DELETED Matches if the task has deleted status
DUE Matches if the task is due
DUETODAY Matches if the task is due today
LATEST Matches if the task is the newest added task
MONTH Matches if the task is due this month
ORPHAN Matches if the task has any orphaned UDA values
OVERDUE Matches if the task is overdue
PARENT Matches if the task is a parent
PENDING Matches if the task has pending status
PRIORITY Matches if the task has a priority
PROJECT Matches if the task has a project
READY Matches if the task is actionable
SCHEDULED Matches if the task is scheduled
TAGGED Matches if the task has tags
@ -682,6 +685,7 @@ are:
WEEK Matches if the task is due this week
YEAR Matches if the task is due this year
YESTERDAY Matches if the task was due sometime yesterday
.\" If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well.
You can use +BLOCKED to filter blocked tasks, or -BLOCKED for unblocked tasks.

View file

@ -32,6 +32,7 @@
#include <string>
#ifdef PRODUCT_TASKWARRIOR
#include <math.h>
#include <ctype.h>
#include <cfloat>
#endif
#include <algorithm>
@ -1170,35 +1171,40 @@ bool Task::hasTag (const std::string& tag) const
// Synthetic tags - dynamically generated, but do not occupy storage space.
// Note: This list must match that in CmdInfo::execute.
// Note: This list must match that in ::feedback_reserved_tags.
if (tag == "BLOCKED") return is_blocked;
if (tag == "UNBLOCKED") return !is_blocked;
if (tag == "BLOCKING") return is_blocking;
if (isupper (tag[0]))
{
if (tag == "BLOCKED") return is_blocked;
if (tag == "UNBLOCKED") return !is_blocked;
if (tag == "BLOCKING") return is_blocking;
#ifdef PRODUCT_TASKWARRIOR
if (tag == "READY") return is_ready ();
if (tag == "DUE") return is_due ();
if (tag == "DUETODAY") return is_duetoday ();
if (tag == "TODAY") return is_duetoday ();
if (tag == "YESTERDAY") return is_dueyesterday ();
if (tag == "TOMORROW") return is_duetomorrow ();
if (tag == "OVERDUE") return is_overdue ();
if (tag == "WEEK") return is_dueweek ();
if (tag == "MONTH") return is_duemonth ();
if (tag == "YEAR") return is_dueyear ();
if (tag == "READY") return is_ready ();
if (tag == "DUE") return is_due ();
if (tag == "DUETODAY") return is_duetoday ();
if (tag == "TODAY") return is_duetoday ();
if (tag == "YESTERDAY") return is_dueyesterday ();
if (tag == "TOMORROW") return is_duetomorrow ();
if (tag == "OVERDUE") return is_overdue ();
if (tag == "WEEK") return is_dueweek ();
if (tag == "MONTH") return is_duemonth ();
if (tag == "YEAR") return is_dueyear ();
#endif
if (tag == "ACTIVE") return has ("start");
if (tag == "SCHEDULED") return has ("scheduled");
if (tag == "CHILD") return has ("parent");
if (tag == "UNTIL") return has ("until");
if (tag == "ANNOTATED") return hasAnnotations ();
if (tag == "TAGGED") return has ("tags");
if (tag == "PARENT") return has ("mask");
if (tag == "WAITING") return get ("status") == "waiting";
if (tag == "PENDING") return get ("status") == "pending";
if (tag == "COMPLETED") return get ("status") == "completed";
if (tag == "DELETED") return get ("status") == "deleted";
if (tag == "UDA") return is_udaPresent ();
if (tag == "ORPHAN") return is_orphanPresent ();
if (tag == "LATEST") return id == context.tdb2.latest_id ();
if (tag == "ACTIVE") return has ("start");
if (tag == "SCHEDULED") return has ("scheduled");
if (tag == "CHILD") return has ("parent");
if (tag == "UNTIL") return has ("until");
if (tag == "ANNOTATED") return hasAnnotations ();
if (tag == "TAGGED") return has ("tags");
if (tag == "PARENT") return has ("mask");
if (tag == "WAITING") return get ("status") == "waiting";
if (tag == "PENDING") return get ("status") == "pending";
if (tag == "COMPLETED") return get ("status") == "completed";
if (tag == "DELETED") return get ("status") == "deleted";
if (tag == "UDA") return is_udaPresent ();
if (tag == "ORPHAN") return is_orphanPresent ();
if (tag == "LATEST") return id == context.tdb2.latest_id ();
if (tag == "PROJECT") return has ("project");
if (tag == "PRIORITY") return has ("priority");
}
// Concrete tags.
std::vector <std::string> tags;

View file

@ -338,6 +338,8 @@ int CmdInfo::execute (std::string& output)
if (task.hasTag ("YEAR")) virtualTags += "YEAR ";
if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY ";
if (task.hasTag ("LATEST")) virtualTags += "LATEST ";
if (task.hasTag ("PROJECT")) virtualTags += "PROJECT ";
if (task.hasTag ("PRIORITY")) virtualTags += "PRIORITY ";
// If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well.
row = view.addRow ();

View file

@ -357,30 +357,35 @@ void feedback_reserved_tags (const std::string& tag)
{
// Note: This list must match that in Task::hasTag.
// Note: This list must match that in CmdInfo::execute.
if (tag == "BLOCKED" ||
tag == "UNBLOCKED" ||
if (tag == "ACTIVE" ||
tag == "ANNOTATED" ||
tag == "BLOCKED" ||
tag == "BLOCKING" ||
tag == "READY" ||
tag == "CHILD" ||
tag == "COMPLETED" ||
tag == "DELETED" ||
tag == "DUE" ||
tag == "DUETODAY" ||
tag == "TODAY" ||
tag == "YESTERDAY" ||
tag == "TOMORROW" ||
tag == "OVERDUE" ||
tag == "WEEK" ||
tag == "LATEST" ||
tag == "MONTH" ||
tag == "YEAR" ||
tag == "ACTIVE" ||
tag == "SCHEDULED" ||
tag == "CHILD" ||
tag == "UNTIL" ||
tag == "ANNOTATED" ||
tag == "TAGGED" ||
tag == "ORPHAN" ||
tag == "OVERDUE" ||
tag == "PARENT" ||
tag == "WAITING" ||
tag == "PENDING" ||
tag == "COMPLETED" ||
tag == "DELETED")
tag == "PRIORITY" ||
tag == "PROJECT" ||
tag == "READY" ||
tag == "SCHEDULED" ||
tag == "TAGGED" ||
tag == "TODAY" ||
tag == "TOMORROW" ||
tag == "UDA" ||
tag == "UNBLOCKED" ||
tag == "UNTIL" ||
tag == "WAITING" ||
tag == "WEEK" ||
tag == "YEAR" ||
tag == "YESTERDAY")
{
throw format (STRING_FEEDBACK_TAG_VIRTUAL, tag);
}