mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
New 'ids' command, and stdin reading
- New 'ids' command that returns a filtered set of task ID numbers, instead of the actual tasks. 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
This commit is contained in:
parent
dd8bceecf7
commit
9470e9af17
22 changed files with 173 additions and 50 deletions
|
@ -2398,6 +2398,36 @@ int handleCount (std::string& outs)
|
|||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleIds (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-ids-command"))
|
||||
{
|
||||
// Scan the pending tasks, applying any filter.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
handleRecurrence ();
|
||||
context.tdb.load (tasks, context.filter);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Find number of matching tasks.
|
||||
std::vector <int> ids;
|
||||
foreach (task, tasks)
|
||||
if (task->id)
|
||||
ids.push_back (task->id);
|
||||
|
||||
std::sort (ids.begin (), ids.end ());
|
||||
outs = compressIds (ids) + "\n";
|
||||
|
||||
context.hooks.trigger ("post-ids-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef FEATURE_SHELL
|
||||
void handleShell ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue