mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
Helper Command
- Added _query helper command for script writers, which accepts a filter like any other report, but returns raw JSON.
This commit is contained in:
parent
126a3d88b5
commit
7f32435ce9
8 changed files with 72 additions and 0 deletions
|
@ -552,6 +552,46 @@ int handleUrgency (std::string& outs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleQuery (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (context.hooks.trigger ("pre-query-command"))
|
||||
{
|
||||
// Get all the tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
handleRecurrence ();
|
||||
context.tdb.load (tasks, context.filter);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Filter sequence.
|
||||
if (context.sequence.size ())
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
|
||||
// Note: "limit:" feature not supported.
|
||||
|
||||
// Compose output.
|
||||
outs = "{";
|
||||
std::vector <Task>::iterator t;
|
||||
for (t = tasks.begin (); t != tasks.end (); ++t)
|
||||
{
|
||||
if (t != tasks.begin ())
|
||||
outs += ",\n";
|
||||
|
||||
outs += t->composeJSON ();
|
||||
}
|
||||
|
||||
outs += "}\n";
|
||||
|
||||
context.hooks.trigger ("post-query-command");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleCompletionIDs (std::string& outs)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue