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

Method execute

src/commands/CmdDenotate.cpp:61–151  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

59
60////////////////////////////////////////////////////////////////////////////////
61int CmdDenotate::execute(std::string&) {
62 auto rc = 0;
63 auto count = 0;
64 auto sensitive = Context::getContext().config.getBoolean("search.case.sensitive");
65
66 // Apply filter.
67 Filter filter;
68 std::vector<Task> filtered;
69 filter.subset(filtered);
70 if (filtered.size() == 0) {
71 Context::getContext().footnote("No tasks specified.");
72 return 1;
73 }
74
75 // Extract all the ORIGINAL MODIFICATION args as simple text patterns.
76 std::string pattern = "";
77 for (auto& a : Context::getContext().cli2._args) {
78 if (a.hasTag("MISCELLANEOUS")) {
79 if (pattern != "") pattern += ' ';
80
81 pattern += a.attribute("raw");
82 }
83 }
84
85 // Accumulated project change notifications.
86 std::map<std::string, std::string> projectChanges;
87
88 if (filtered.size() > 1) {
89 feedback_affected("This command will alter {1} tasks.", filtered.size());
90 }
91 for (auto& task : filtered) {
92 Task before(task);
93
94 auto annotations = task.getAnnotations();
95
96 if (annotations.size() == 0)
97 throw std::string("The specified task has no annotations that can be deleted.");
98
99 std::string anno;
100 auto match = false;
101 for (auto i = annotations.begin(); i != annotations.end(); ++i) {
102 if (i->second == pattern) {
103 match = true;
104 anno = i->second;
105 annotations.erase(i);
106 task.setAnnotations(annotations);
107 break;
108 }
109 }
110
111 if (!match) {
112 for (auto i = annotations.begin(); i != annotations.end(); ++i) {
113 auto loc = find(i->second, pattern, sensitive);
114 if (loc != std::string::npos) {
115 anno = i->second;
116 annotations.erase(i);
117 task.setAnnotations(annotations);
118 break;

Callers

nothing calls this directly

Calls 13

feedback_affectedFunction · 0.85
onProjectChangeFunction · 0.85
subsetMethod · 0.80
footnoteMethod · 0.80
attributeMethod · 0.80
getAnnotationsMethod · 0.80
setAnnotationsMethod · 0.80
identifierMethod · 0.80
diffMethod · 0.80
verboseMethod · 0.80
hasTagMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected