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

Method demotion

src/CLI2.cpp:421–449  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// [1] Scan all args for the 'add' and 'log' commands, and demote any Lexer::Type::Tag args with sign '-' to Lexer::Type::word. [2] Convert any pseudo args name:value into config settings, and erase.

Source from the content-addressed store, hash-verified

419// Lexer::Type::Tag args with sign '-' to Lexer::Type::word.
420// [2] Convert any pseudo args name:value into config settings, and erase.
421void CLI2::demotion() {
422 bool changes = false;
423 std::vector<A2> replacement;
424
425 std::string canonical;
426 for (auto& a : _args) {
427 if (a._lextype == Lexer::Type::tag && a.attribute("sign") == "-") {
428 std::string command = getCommand();
429 if (command == "add" || command == "log") {
430 a._lextype = Lexer::Type::word;
431 changes = true;
432 }
433 }
434
435 else if (a._lextype == Lexer::Type::pair &&
436 canonicalize(canonical, "pseudo", a.attribute("name"))) {
437 Context::getContext().config.set(canonical, a.attribute("value"));
438 changes = true;
439
440 // Equivalent to erasing 'a'.
441 continue;
442 }
443
444 replacement.push_back(a);
445 }
446
447 if (changes && Context::getContext().config.getInteger("debug.parser") >= 2)
448 Context::getContext().debug(dump("CLI2::analyze demotion"));
449}
450
451////////////////////////////////////////////////////////////////////////////////
452// Intended to be called after ::add() to perform the final analysis.

Callers

nothing calls this directly

Calls 3

attributeMethod · 0.80
setMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected