diff --git a/ChangeLog b/ChangeLog index 82901bde3..b147ddfdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,8 @@ # Untracked Features, biggest first. + autoconf eliminated. + New 'ids' command that returns a filtered set of task ID numbers, instead - of the actual tasks. For advanced pipeline use. + of the actual tasks. Similarly there is a 'uuids' commands. For advanced + pipeline use. + Now supplements the command line with data read from standard input, which allows commands like: echo 'add Pay the bills' | task + Corrected sorting to use std::stable_sort instead of std::sort, which is not @@ -38,6 +39,7 @@ + The configuration variable 'json.array' determines whether 'query' command output is enclosed by '[...]'. + The duration 'm' is now interpreted as 'months', not 'minutes'. + # Tracked Features, sorted by ID. + Added feature #278, which provides a more consistent command line grammar. diff --git a/NEWS b/NEWS index 241bef52b..88f474f55 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,8 @@ New Features in taskwarrior 2.0.0 - New 'ids' command that returns a filtered set of task ID numbers, instead - of the actual tasks. For advanced pipeline use. + of the actual tasks. Similarly, there is a 'uuids' command. For advanced + pipeline use. - Now supplements the command line with data read from standard input, which allows commands like: echo 'add Pay the bills' | task - Attribute modifiers may be prefixed with '~' to return the opposite of a diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 7a002181f..220360c8e 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -177,6 +177,17 @@ to achieve this: This example first gets the IDs for the project:Home filter, then sets the priority to H for each of those tasks. +.TP +.B task uuids +Applies the filter then extracts only the task UUIDs and presents them as +a comma-separated list. This is useful as input to a task command, to achieve +this: + + task $(task project:Home status:completed uuids) modify status:pending + +This example first gets the UUIDs for the project:Home and status:completed +filter, then makes each of those tasks pending again. + .TP .B task information Shows all data and metadata for the specified tasks. diff --git a/src/commands/CmdIDs.cpp b/src/commands/CmdIDs.cpp index 5faf83613..59b457468 100644 --- a/src/commands/CmdIDs.cpp +++ b/src/commands/CmdIDs.cpp @@ -25,13 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// - #define L10N // Localization complete. #include #include #include #include +#include #include #include #include @@ -139,3 +139,32 @@ int CmdZshCompletionIds::execute (std::string& output) } //////////////////////////////////////////////////////////////////////////////// +CmdUUIDs::CmdUUIDs () +{ + _keyword = "uuids"; + _usage = "task uuids"; + _description = STRING_CMD_UUIDS_USAGE; + _read_only = true; + _displays_id = false; +} + +//////////////////////////////////////////////////////////////////////////////// +int CmdUUIDs::execute (std::string& output) +{ + // Apply filter. + handleRecurrence (); + std::vector filtered; + filter (filtered); + context.tdb2.commit (); + + std::vector uuids; + std::vector ::iterator task; + for (task = filtered.begin (); task != filtered.end (); ++task) + uuids.push_back (task->get ("uuid")); + + join (output, ",", uuids); + output += "\n"; + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdIDs.h b/src/commands/CmdIDs.h index 0e65cdfbc..a5778ac48 100644 --- a/src/commands/CmdIDs.h +++ b/src/commands/CmdIDs.h @@ -53,5 +53,12 @@ public: int execute (std::string&); }; +class CmdUUIDs : public Command +{ +public: + CmdUUIDs (); + int execute (std::string&); +}; + #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 8140f0021..83c406c0f 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -156,6 +156,7 @@ void Command::factory (std::map & all) c = new CmdTimesheet (); all[c->keyword ()] = c; c = new CmdUndo (); all[c->keyword ()] = c; c = new CmdUrgency (); all[c->keyword ()] = c; + c = new CmdUUIDs (); all[c->keyword ()] = c; c = new CmdVersion (); all[c->keyword ()] = c; c = new CmdZshCommands (); all[c->keyword ()] = c; c = new CmdZshCompletionIds (); all[c->keyword ()] = c; diff --git a/src/en-US.h b/src/en-US.h index 846331701..36c95fae6 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -209,6 +209,7 @@ #define STRING_CMD_IDS_USAGE_RANGE "Shows the IDs of matching tasks, as a range" #define STRING_CMD_IDS_USAGE_LIST "Shows only the IDs of matching tasks, in the form of a list" #define STRING_CMD_IDS_USAGE_ZSH "Shows the IDs and descriptions of matching tasks" +#define STRING_CMD_UUIDS_USAGE "Shows the UUIDs of matching tasks" #define STRING_CMD_EXPORT_USAGE "Exports tasks in JSON format" #define STRING_CMD_INFO_USAGE "Shows all data and metadata" #define STRING_CMD_INFO_BLOCKED "This task blocked by"