mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 22:47:20 +02:00
Enhancement
- Added new _ids command to support tab completion scripts.
This commit is contained in:
parent
02c7d7607c
commit
ca4bae558d
4 changed files with 30 additions and 0 deletions
|
@ -109,6 +109,7 @@ void Cmd::load ()
|
||||||
commands.push_back ("_projects");
|
commands.push_back ("_projects");
|
||||||
commands.push_back ("_tags");
|
commands.push_back ("_tags");
|
||||||
commands.push_back ("_commands");
|
commands.push_back ("_commands");
|
||||||
|
commands.push_back ("_ids");
|
||||||
commands.push_back (context.stringtable.get (CMD_ADD, "add"));
|
commands.push_back (context.stringtable.get (CMD_ADD, "add"));
|
||||||
commands.push_back (context.stringtable.get (CMD_APPEND, "append"));
|
commands.push_back (context.stringtable.get (CMD_APPEND, "append"));
|
||||||
commands.push_back (context.stringtable.get (CMD_ANNOTATE, "annotate"));
|
commands.push_back (context.stringtable.get (CMD_ANNOTATE, "annotate"));
|
||||||
|
@ -197,6 +198,7 @@ bool Cmd::isReadOnlyCommand ()
|
||||||
if (command == "_projects" ||
|
if (command == "_projects" ||
|
||||||
command == "_tags" ||
|
command == "_tags" ||
|
||||||
command == "_commands" ||
|
command == "_commands" ||
|
||||||
|
command == "_ids" ||
|
||||||
command == context.stringtable.get (CMD_CALENDAR, "calendar") ||
|
command == context.stringtable.get (CMD_CALENDAR, "calendar") ||
|
||||||
command == context.stringtable.get (CMD_COLORS, "colors") ||
|
command == context.stringtable.get (CMD_COLORS, "colors") ||
|
||||||
command == context.stringtable.get (CMD_EXPORT, "export") ||
|
command == context.stringtable.get (CMD_EXPORT, "export") ||
|
||||||
|
|
|
@ -199,6 +199,7 @@ std::string Context::dispatch ()
|
||||||
else if (cmd.command == "_projects") { out = handleCompletionProjects (); }
|
else if (cmd.command == "_projects") { out = handleCompletionProjects (); }
|
||||||
else if (cmd.command == "_tags") { out = handleCompletionTags (); }
|
else if (cmd.command == "_tags") { out = handleCompletionTags (); }
|
||||||
else if (cmd.command == "_commands") { out = handleCompletionCommands (); }
|
else if (cmd.command == "_commands") { out = handleCompletionCommands (); }
|
||||||
|
else if (cmd.command == "_ids") { out = handleCompletionIDs (); }
|
||||||
else if (cmd.command == "" &&
|
else if (cmd.command == "" &&
|
||||||
sequence.size ()) { out = handleModify (); }
|
sequence.size ()) { out = handleModify (); }
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,32 @@ std::string handleCompletionCommands ()
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string handleCompletionIDs ()
|
||||||
|
{
|
||||||
|
std::vector <Task> tasks;
|
||||||
|
context.tdb.lock (context.config.get ("locking", true));
|
||||||
|
handleRecurrence ();
|
||||||
|
Filter filter;
|
||||||
|
context.tdb.loadPending (tasks, filter);
|
||||||
|
context.tdb.commit ();
|
||||||
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
std::vector <int> ids;
|
||||||
|
foreach (task, tasks)
|
||||||
|
if (task->getStatus () != Task::deleted &&
|
||||||
|
task->getStatus () != Task::completed)
|
||||||
|
ids.push_back (task->id);
|
||||||
|
|
||||||
|
std::sort (ids.begin (), ids.end ());
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
|
foreach (id, ids)
|
||||||
|
out << *id << std::endl;
|
||||||
|
|
||||||
|
return out.str ();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void handleUndo ()
|
void handleUndo ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,6 +64,7 @@ std::string handleCompletionProjects ();
|
||||||
std::string handleTags ();
|
std::string handleTags ();
|
||||||
std::string handleCompletionTags ();
|
std::string handleCompletionTags ();
|
||||||
std::string handleCompletionCommands ();
|
std::string handleCompletionCommands ();
|
||||||
|
std::string handleCompletionIDs ();
|
||||||
std::string handleVersion ();
|
std::string handleVersion ();
|
||||||
std::string handleDelete ();
|
std::string handleDelete ();
|
||||||
std::string handleStart ();
|
std::string handleStart ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue