Enhancements - stop command

- Implemented stop command
- Fixed bug in TDB that failed to truncate the pending file on
  update.
This commit is contained in:
Paul Beckingham 2009-06-15 23:59:56 -04:00
parent 1551362d1e
commit 41e137a92c
3 changed files with 31 additions and 13 deletions

View file

@ -192,9 +192,7 @@ std::string Context::dispatch ()
else if (cmd.command == "undelete") { out = handleUndelete (); }
*/
else if (cmd.command == "start") { out = handleStart (); }
/*
else if (cmd.command == "stop") { out = handleStop (); }
*/
else if (cmd.command == "export") { out = handleExport (); }
/*
else if (cmd.command == "import") { out = handleImport (); }

View file

@ -312,8 +312,11 @@ int TDB::commit ()
// Write out all pending.
if (fseek (mLocations[0].pending, 0, SEEK_SET) == 0)
{
ftruncate (fileno (mLocations[0].pending), 0);
foreach (task, mPending)
fputs (task->composeF4 ().c_str (), mLocations[0].pending);
}
}
return quantity;

View file

@ -570,27 +570,44 @@ std::string handleStart ()
std::string handleStop ()
{
std::stringstream out;
/*
std::vector <T> all;
tdb.pendingT (all);
filterSequence (all, task);
foreach (t, all)
std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true));
context.tdb.loadPending (tasks, context.filter);
handleRecurrence (tasks);
// Filter sequence.
context.filter.applySequence (tasks, context.sequence);
foreach (task, tasks)
{
if (t->has ("start"))
if (task->has ("start"))
{
t->removeAttribute ("start");
tdb.modifyT (*t);
task->remove ("start");
context.tdb.update (*task);
if (context.config.get ("echo.command", true))
out << "Stopped " << t->getId () << " '" << t->getDescription () << "'" << std::endl;
out << "Stopped "
<< task->id
<< " '"
<< task->get ("description")
<< "'"
<< std::endl;
}
else
{
out << "Task " << t->getId () << " '" << t->getDescription () << "' not started." << std::endl;
out << "Task "
<< task->id
<< " '"
<< task->get ("description")
<< "' not started."
<< std::endl;
}
}
*/
context.tdb.commit ();
context.tdb.unlock ();
return out.str ();
}