///////////////////////////////////////////////////////////////////////////
| 175 | |
| 176 | //////////////////////////////////////////////////////////////////////////////// |
| 177 | std::string CmdEdit::formatTask(Task task, const std::string& dateformat) { |
| 178 | std::stringstream before; |
| 179 | auto verbose = Context::getContext().verbose("edit"); |
| 180 | |
| 181 | if (verbose) |
| 182 | before << "# The 'task <id> edit' command allows you to modify all aspects of a task\n" |
| 183 | "# using a text editor. Below is a representation of all the task details.\n" |
| 184 | "# Modify what you wish, and when you save and quit your editor,\n" |
| 185 | "# Taskwarrior will read this file, determine what changed, and apply\n" |
| 186 | "# those changes. If you exit your editor without saving or making\n" |
| 187 | "# modifications, Taskwarrior will do nothing.\n" |
| 188 | "#\n" |
| 189 | "# Lines that begin with # represent data you cannot change, like ID.\n" |
| 190 | "# If you get too creative with your editing, Taskwarrior will send you\n" |
| 191 | "# back to the editor to try again.\n" |
| 192 | "#\n" |
| 193 | "# Should you find yourself in an endless loop, re-editing the same file,\n" |
| 194 | "# just quit the editor without making any changes. Taskwarrior will\n" |
| 195 | "# notice this and stop the editing.\n" |
| 196 | "#\n"; |
| 197 | |
| 198 | before << "# Name Editable details\n" |
| 199 | << "# ----------------- ----------------------------------------------------\n" |
| 200 | << "# ID: " << task.id << '\n' |
| 201 | << "# UUID: " << task.get("uuid") << '\n' |
| 202 | << "# Status: " << Lexer::ucFirst(Task::statusToText(task.getStatus())) << '\n' |
| 203 | << "# Mask: " << task.get("mask") << '\n' |
| 204 | << "# iMask: " << task.get("imask") << '\n' |
| 205 | << " Project: " << task.get("project") << '\n'; |
| 206 | |
| 207 | if (verbose) before << "# Separate the tags with spaces, like this: tag1 tag2\n"; |
| 208 | |
| 209 | before << " Tags: " << join(" ", task.getTags()) << '\n' |
| 210 | << " Description: " << task.get("description") << '\n' |
| 211 | << " Created: " << formatDate(task, "entry", dateformat) << '\n' |
| 212 | << " Started: " << formatDate(task, "start", dateformat) << '\n' |
| 213 | << " Ended: " << formatDate(task, "end", dateformat) << '\n' |
| 214 | << " Scheduled: " << formatDate(task, "scheduled", dateformat) << '\n' |
| 215 | << " Due: " << formatDate(task, "due", dateformat) << '\n' |
| 216 | << " Until: " << formatDate(task, "until", dateformat) << '\n' |
| 217 | << " Recur: " << task.get("recur") << '\n' |
| 218 | << " Wait until: " << formatDate(task, "wait", dateformat) << '\n' |
| 219 | << "# Modified: " << formatDate(task, "modified", dateformat) << '\n' |
| 220 | << " Parent: " << task.get("parent") << '\n'; |
| 221 | |
| 222 | if (verbose) |
| 223 | before |
| 224 | << "# Annotations look like this: <date> -- <text> and there can be any number of them.\n" |
| 225 | "# The ' -- ' separator between the date and text field should not be removed.\n" |
| 226 | "# Multiline annotations need to be indented up to <date> (" |
| 227 | << ANNOTATION_EDIT_MARKER.length() - 1 |
| 228 | << " spaces).\n" |
| 229 | "# A \"blank slot\" for adding an annotation follows for your convenience.\n"; |
| 230 | |
| 231 | for (auto& anno : task.getAnnotations()) { |
| 232 | Datetime dt(strtoll(anno.first.substr(11).c_str(), nullptr, 10)); |
| 233 | before << " Annotation: " << dt.toString(dateformat) << " -- " |
| 234 | << str_replace(anno.second, "\n", ANNOTATION_EDIT_MARKER) << '\n'; |
nothing calls this directly
no test coverage detected