/////////////////////////////////////////////////////////////////////////// Introducing the Silver Bullet. This feature is the catch-all fixative for various other ills. This is like opening up the hood and going in with a wrench. To be used sparingly.
| 76 | // various other ills. This is like opening up the hood and going in with a |
| 77 | // wrench. To be used sparingly. |
| 78 | int CmdEdit::execute(std::string&) { |
| 79 | // Filter the tasks. |
| 80 | Filter filter; |
| 81 | std::vector<Task> filtered; |
| 82 | filter.subset(filtered); |
| 83 | |
| 84 | if (!filtered.size()) { |
| 85 | Context::getContext().footnote("No matches."); |
| 86 | return 1; |
| 87 | } |
| 88 | |
| 89 | unsigned int bulk = Context::getContext().config.getInteger("bulk"); |
| 90 | |
| 91 | // If we are editing more than "bulk" tasks, ask for confirmation. |
| 92 | // Bulk = 0 denotes infinite bulk. |
| 93 | if ((filtered.size() > bulk) && (bulk != 0)) |
| 94 | if (!confirm(format("Do you wish to manually edit {1} tasks?", filtered.size()))) return 2; |
| 95 | |
| 96 | // Find number of matching tasks. |
| 97 | for (auto& task : filtered) { |
| 98 | auto result = editFile(task); |
| 99 | if (result == CmdEdit::editResult::error) |
| 100 | break; |
| 101 | else if (result == CmdEdit::editResult::changes) |
| 102 | Context::getContext().tdb2.modify(task); |
| 103 | } |
| 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | //////////////////////////////////////////////////////////////////////////////// |
| 109 | std::string CmdEdit::findValue(const std::string& text, const std::string& name) { |