mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Commands - start
- Migrated handleStart to CmdStart.
This commit is contained in:
parent
0429949de5
commit
86ab605bd4
9 changed files with 156 additions and 73 deletions
|
@ -551,71 +551,6 @@ int handleDelete (std::string& outs)
|
|||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleStart (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
std::stringstream out;
|
||||
|
||||
context.disallowModification ();
|
||||
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
Filter filter;
|
||||
context.tdb.loadPending (tasks, filter);
|
||||
|
||||
// Filter sequence.
|
||||
context.filter.applySequence (tasks, context.sequence);
|
||||
if (tasks.size () == 0)
|
||||
{
|
||||
std::cout << "No tasks specified.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool nagged = false;
|
||||
foreach (task, tasks)
|
||||
{
|
||||
if (! task->has ("start"))
|
||||
{
|
||||
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);
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Started "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "'.\n";
|
||||
if (!nagged)
|
||||
nagged = nag (*task);
|
||||
|
||||
dependencyChainOnStart (*task);
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "Task "
|
||||
<< task->id
|
||||
<< " '"
|
||||
<< task->get ("description")
|
||||
<< "' already started.\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
outs = out.str ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleStop (std::string& outs)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue