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

Method getTaskContext

src/Context.cpp:946–973  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

944
945////////////////////////////////////////////////////////////////////////////////
946std::string Context::getTaskContext(const std::string& kind, std::string name,
947 bool fallback /* = true */) {
948 // Consider currently selected context, if none specified
949 if (name.empty()) name = config.get("context");
950
951 // Detect if any context is set, and bail out if not
952 if (!name.empty())
953 debug(format("Applying context '{1}'", name));
954 else {
955 debug("No context set");
956 return "";
957 }
958
959 // Figure out the context string for this kind (read/write)
960 std::string contextString = "";
961
962 if (!config.has("context." + name + "." + kind) && kind == "read") {
963 debug("Specific " + kind + " context for '" + name + "' not defined. ");
964 if (fallback) {
965 debug("Trying to interpret old-style context definition as read context.");
966 contextString = config.get("context." + name);
967 }
968 } else
969 contextString = config.get("context." + name + "." + kind);
970
971 debug(format("Detected context string: {1}", contextString.empty() ? "(empty)" : contextString));
972 return contextString;
973}
974
975////////////////////////////////////////////////////////////////////////////////
976bool Context::color() {

Callers 3

addContextMethod · 0.80
listContextsMethod · 0.80
showContextMethod · 0.80

Calls 2

getMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected