Commands - log
- Migrated handleLog to CmdLog.
This commit is contained in:
@@ -51,74 +51,6 @@
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleLog (std::string& outs)
|
||||
{
|
||||
int rc = 0;
|
||||
std::stringstream out;
|
||||
|
||||
context.task.setStatus (Task::completed);
|
||||
context.task.set ("uuid", uuid ());
|
||||
context.task.setEntry ();
|
||||
|
||||
// Add an end date.
|
||||
char entryTime[16];
|
||||
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
||||
context.task.set ("end", entryTime);
|
||||
|
||||
// Recurring tasks get a special status.
|
||||
if (context.task.has ("recur"))
|
||||
throw std::string ("You cannot log recurring tasks.");
|
||||
|
||||
if (context.task.has ("wait"))
|
||||
throw std::string ("You cannot log waiting tasks.");
|
||||
|
||||
// It makes no sense to add dependencies to an already-completed task.
|
||||
if (context.task.get ("depends") != "")
|
||||
throw std::string ("You cannot specify dependencies on a completed task.");
|
||||
|
||||
// Override with default.project, if not specified.
|
||||
if (context.task.get ("project") == "")
|
||||
context.task.set ("project", context.config.get ("default.project"));
|
||||
|
||||
// Override with default.priority, if not specified.
|
||||
if (context.task.get ("priority") == "")
|
||||
{
|
||||
std::string defaultPriority = context.config.get ("default.priority");
|
||||
if (Att::validNameValue ("priority", "", defaultPriority))
|
||||
context.task.set ("priority", defaultPriority);
|
||||
}
|
||||
|
||||
// Override with default.due, if not specified.
|
||||
if (context.task.get ("due") == "")
|
||||
{
|
||||
std::string defaultDue = context.config.get ("default.due");
|
||||
if (defaultDue != "" &&
|
||||
Att::validNameValue ("due", "", defaultDue))
|
||||
context.task.set ("due", defaultDue);
|
||||
}
|
||||
|
||||
// Include tags.
|
||||
foreach (tag, context.tagAdditions)
|
||||
context.task.addTag (*tag);
|
||||
|
||||
// Only valid tasks can be added.
|
||||
context.task.validate ();
|
||||
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
context.tdb.add (context.task);
|
||||
context.tdb.commit ();
|
||||
|
||||
if (context.config.getBoolean ("echo.command"))
|
||||
out << "Logged task.\n";
|
||||
|
||||
context.footnote (onProjectChange (context.task));
|
||||
context.tdb.unlock ();
|
||||
|
||||
outs = out.str ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int handleCompletionConfig (std::string& outs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user