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

Function getDOM

src/DOM.cpp:66–175  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// DOM Supported References: Configuration: rc. Taskwarrior: tw.syncneeded tw.program tw.args tw.width tw.height tw.version System: context.program // 2017-02-25 Deprecated in 2.6.0 context.args // 2017-02-25 Deprecated in 2.6.0 context.width // 2017-02-25 Deprecated in 2.6.0 context.heig

Source from the content-addressed store, hash-verified

64// system.os
65//
66bool getDOM(const std::string& name, Variant& value) {
67 // Special case, blank refs cause problems.
68 if (name == "") return false;
69
70 auto len = name.length();
71
72 // rc. --> context.config
73 if (len > 3 && !name.compare(0, 3, "rc.", 3)) {
74 auto key = name.substr(3);
75 auto c = Context::getContext().config.find(key);
76 if (c != Context::getContext().config.end()) {
77 value = Variant(c->second);
78 return true;
79 }
80
81 return false;
82 }
83
84 // tw.*
85 if (len > 3 && !name.compare(0, 3, "tw.", 3)) {
86 if (name == "tw.syncneeded") {
87 value = Variant(0);
88 if (Context::getContext().tdb2.num_local_changes() > 0) {
89 value = Variant(1);
90 }
91
92 return true;
93 } else if (name == "tw.program") {
94 value = Variant(Context::getContext().cli2.getBinary());
95 return true;
96 } else if (name == "tw.args") {
97 std::string commandLine;
98 for (auto& arg : Context::getContext().cli2._original_args) {
99 if (commandLine != "") commandLine += ' ';
100
101 commandLine += arg.attribute("raw");
102 }
103
104 value = Variant(commandLine);
105 return true;
106 } else if (name == "tw.width") {
107 value = Variant(static_cast<int>(Context::getContext().terminal_width
108 ? Context::getContext().terminal_width
109 : Context::getContext().getWidth()));
110 return true;
111 } else if (name == "tw.height") {
112 value = Variant(static_cast<int>(Context::getContext().terminal_height
113 ? Context::getContext().terminal_height
114 : Context::getContext().getHeight()));
115 return true;
116 }
117
118 else if (name == "tw.version") {
119 value = Variant(VERSION);
120 return true;
121 }
122
123 return false;

Callers 3

domSourceFunction · 0.85
Hooks.cppFile · 0.85
executeMethod · 0.85

Calls 15

VariantClass · 0.85
findMethod · 0.80
num_local_changesMethod · 0.80
getBinaryMethod · 0.80
attributeMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
urgency_cMethod · 0.80
tokenMethod · 0.80
canonicalizeMethod · 0.80
statusToTextMethod · 0.80
getStatusMethod · 0.80

Tested by

no test coverage detected