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

Method applyOverrides

src/CLI2.cpp:236–256  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Static method.

Source from the content-addressed store, hash-verified

234////////////////////////////////////////////////////////////////////////////////
235// Static method.
236void CLI2::applyOverrides(int argc, const char** argv) {
237 auto& context = Context::getContext();
238 auto last = std::find(argv, argv + argc, std::string("--"));
239 auto is_override = [](const std::string& s) { return s.compare(0, 3, "rc.") == 0; };
240 auto get_sep = [&](const std::string& s) {
241 if (is_override(s)) return s.find_first_of(":=", 3);
242 return std::string::npos;
243 };
244 auto override_settings = [&](std::string raw) {
245 auto sep = get_sep(raw);
246 if (sep == std::string::npos) return;
247 std::string name = raw.substr(3, sep - 3);
248 std::string value = raw.substr(sep + 1);
249 context.config.set(name, value);
250 };
251 auto display_overrides = [&](std::string raw) {
252 if (is_override(raw)) context.footnote(format("Configuration override {1}", raw));
253 };
254 std::for_each(argv, last, override_settings);
255 if (context.verbose("override")) std::for_each(argv, last, display_overrides);
256}
257
258////////////////////////////////////////////////////////////////////////////////
259void CLI2::alias(const std::string& name, const std::string& value) { _aliases[name] = value; }

Callers

nothing calls this directly

Calls 3

setMethod · 0.80
footnoteMethod · 0.80
verboseMethod · 0.80

Tested by

no test coverage detected