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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user