Commands - stop

- Migrated handleStop to CmdStop.
This commit is contained in:
Paul Beckingham
2011-05-30 01:19:11 -04:00
parent 86ab605bd4
commit 9e3c6f5bc1
9 changed files with 148 additions and 65 deletions

View File

@@ -551,63 +551,6 @@ int handleDelete (std::string& outs)
return rc;
}
////////////////////////////////////////////////////////////////////////////////
int handleStop (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;
}
foreach (task, tasks)
{
if (task->has ("start"))
{
task->remove ("start");
if (context.config.getBoolean ("journal.time"))
task->addAnnotation (context.config.get ("journal.time.stop.annotation"));
context.tdb.update (*task);
if (context.config.getBoolean ("echo.command"))
out << "Stopped "
<< task->id
<< " '"
<< task->get ("description")
<< "'.\n";
}
else
{
out << "Task "
<< task->id
<< " '"
<< task->get ("description")
<< "' not started.\n";
rc = 1;
}
}
context.tdb.commit ();
context.tdb.unlock ();
outs = out.str ();
return rc;
}
////////////////////////////////////////////////////////////////////////////////
int handleDone (std::string& outs)
{