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

Method execute

src/commands/CmdModify.cpp:61–107  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

59
60////////////////////////////////////////////////////////////////////////////////
61int CmdModify::execute(std::string&) {
62 auto rc = 0;
63
64 // Apply filter.
65 Filter filter;
66 std::vector<Task> filtered;
67 filter.subset(filtered);
68 if (filtered.size() == 0) {
69 Context::getContext().footnote("No tasks specified.");
70 return 1;
71 }
72
73 // Accumulated project change notifications.
74 std::map<std::string, std::string> projectChanges;
75
76 auto count = 0;
77 if (filtered.size() > 1) {
78 feedback_affected("This command will alter {1} tasks.", filtered.size());
79 }
80 for (auto& task : filtered) {
81 Task before(task);
82 task.modify(Task::modReplace);
83
84 if (before != task) {
85 // Abort if change introduces inconsistencies.
86 checkConsistency(before, task);
87
88 auto question =
89 format("Modify task {1} '{2}'?", task.identifier(true), task.get("description"));
90
91 if (permission(before.diff(task) + question, filtered.size())) {
92 count += modifyAndUpdate(before, task, &projectChanges);
93 } else {
94 std::cout << "Task not modified.\n";
95 rc = 1;
96 if (_permission_quit) break;
97 }
98 }
99 }
100
101 // Now list the project changes.
102 for (const auto& change : projectChanges)
103 if (change.first != "") Context::getContext().footnote(change.second);
104
105 feedback_affected(count == 1 ? "Modified {1} task." : "Modified {1} tasks.", count);
106 return rc;
107}
108
109////////////////////////////////////////////////////////////////////////////////
110// TODO Why is this not in Task::validate?

Callers

nothing calls this directly

Calls 7

feedback_affectedFunction · 0.85
subsetMethod · 0.80
footnoteMethod · 0.80
identifierMethod · 0.80
diffMethod · 0.80
modifyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected