MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / parseTask

Method parseTask

src/commands/CmdEdit.cpp:305–603  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

303
304////////////////////////////////////////////////////////////////////////////////
305void CmdEdit::parseTask(Task& task, const std::string& after, const std::string& dateformat) {
306 // project
307 auto value = findValue(after, "\n Project:");
308 if (task.get("project") != value) {
309 if (value != "") {
310 Context::getContext().footnote("Project modified.");
311 task.set("project", value);
312 } else {
313 Context::getContext().footnote("Project deleted.");
314 task.remove("project");
315 }
316 }
317
318 // tags
319 value = findValue(after, "\n Tags:");
320 task.setTags(split(value, ' '));
321
322 // description.
323 value = findMultilineValue(after, "\n Description:", "\n Created:");
324 if (task.get("description") != value) {
325 if (value != "") {
326 Context::getContext().footnote("Description modified.");
327 task.set("description", value);
328 } else
329 throw std::string("Cannot remove description.");
330 }
331
332 // entry
333 value = findValue(after, "\n Created:");
334 if (value != "") {
335 if (value != formatDate(task, "entry", dateformat)) {
336 Context::getContext().footnote("Creation date modified.");
337 task.set("entry", Datetime(value, dateformat).toEpochString());
338 }
339 } else
340 throw std::string("Cannot remove creation date.");
341
342 // start
343 value = findValue(after, "\n Started:");
344 if (value != "") {
345 if (task.get("start") != "") {
346 if (value != formatDate(task, "start", dateformat)) {
347 Context::getContext().footnote(STRING_EDIT_START_MOD);
348 task.set("start", Datetime(value, dateformat).toEpochString());
349 }
350 } else {
351 Context::getContext().footnote(STRING_EDIT_START_MOD);
352 task.set("start", Datetime(value, dateformat).toEpochString());
353 }
354 } else {
355 if (task.get("start") != "") {
356 Context::getContext().footnote("Start date removed.");
357 task.remove("start");
358 }
359 }
360
361 // end
362 value = findValue(after, "\n Ended:");

Callers

nothing calls this directly

Calls 13

footnoteMethod · 0.80
setMethod · 0.80
setTagsMethod · 0.80
getStatusMethod · 0.80
setStatusMethod · 0.80
parseMethod · 0.80
findMethod · 0.80
setAnnotationsMethod · 0.80
getDependencyUUIDsMethod · 0.80
removeDependencyMethod · 0.80
addDependencyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected