mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement
- Various commands now allow modification and annotation.
This commit is contained in:
parent
b5f04a3ebc
commit
d087bdfd38
9 changed files with 168 additions and 59 deletions
|
@ -27,7 +27,9 @@
|
|||
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <Permission.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
#include <CmdStart.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -46,50 +48,72 @@ CmdStart::CmdStart ()
|
|||
int CmdStart::execute (std::string& output)
|
||||
{
|
||||
int rc = 0;
|
||||
/*
|
||||
int count = 0;
|
||||
std::stringstream out;
|
||||
|
||||
context.disallowModification ();
|
||||
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
Filter filter;
|
||||
context.tdb.loadPending (tasks, filter);
|
||||
context.tdb.loadPending (tasks);
|
||||
|
||||
// Filter sequence.
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
if (tasks.size () == 0)
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Apply the command line modifications to the started task.
|
||||
Arguments modifications = context.args.extract_modifications ();
|
||||
|
||||
Permission permission;
|
||||
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||
permission.bigSequence ();
|
||||
|
||||
bool nagged = false;
|
||||
std::vector <Task>::iterator task;
|
||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
if (! task->has ("start"))
|
||||
{
|
||||
Task before (*task);
|
||||
|
||||
modify_task_annotate (*task, modifications);
|
||||
apply_defaults (*task);
|
||||
|
||||
// Add a start time.
|
||||
char startTime[16];
|
||||
sprintf (startTime, "%u", (unsigned int) time (NULL));
|
||||
|
||||
task->set ("start", startTime);
|
||||
|
||||
if (context.config.getBoolean ("journal.time"))
|
||||
task->addAnnotation (context.config.get ("journal.time.start.annotation"));
|
||||
|
||||
context.tdb.update (*task);
|
||||
// Only allow valid tasks.
|
||||
task->validate ();
|
||||
|
||||
if (taskDiff (before, *task))
|
||||
{
|
||||
if (permission.confirmed (before, taskDifferences (before, *task) + STRING_CMD_DONE_PROCEED))
|
||||
{
|
||||
context.tdb.update (*task);
|
||||
++count;
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Started "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "'.\n";
|
||||
|
||||
dependencyChainOnStart (*task);
|
||||
}
|
||||
}
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Started "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "'.\n";
|
||||
if (!nagged)
|
||||
nagged = nag (*task);
|
||||
|
||||
dependencyChainOnStart (*task);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -102,11 +126,12 @@ int CmdStart::execute (std::string& output)
|
|||
}
|
||||
}
|
||||
|
||||
context.tdb.commit ();
|
||||
if (count)
|
||||
context.tdb.commit ();
|
||||
|
||||
context.tdb.unlock ();
|
||||
|
||||
output = out.str ();
|
||||
*/
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue