MCPcopy Create free account
hub / github.com/DFHack/dfhack / plug

Method plug

library/Commands.cpp:190–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 command_result Commands::plug(color_ostream& con, Core& core, const std::string& first, const std::vector<std::string>& parts)
191 {
192 constexpr auto header_format = "{:30} {:10} {:4} {:8}\n";
193 constexpr auto row_format = header_format;
194
195 con.print(header_format, "Name", "State", "Cmds", "Enabled");
196
197 auto plug_mgr = core.getPluginManager();
198
199 plug_mgr->refresh();
200 for (auto& [key, plug] : *plug_mgr)
201 {
202 if (!plug)
203 continue;
204
205 if (parts.size() && std::ranges::find(parts, key) == parts.end())
206 continue;
207
208 color_value color;
209 switch (plug->getState())
210 {
211 case Plugin::PS_LOADED:
212 color = COLOR_RESET;
213 break;
214 case Plugin::PS_UNLOADED:
215 case Plugin::PS_UNLOADING:
216 color = COLOR_YELLOW;
217 break;
218 case Plugin::PS_LOADING:
219 color = COLOR_LIGHTBLUE;
220 break;
221 case Plugin::PS_BROKEN:
222 color = COLOR_LIGHTRED;
223 break;
224 default:
225 color = COLOR_LIGHTMAGENTA;
226 break;
227 }
228 con.color(color);
229 con.print(row_format,
230 plug->getName(),
231 Plugin::getStateDescription(plug->getState()),
232 plug->size(),
233 (plug->can_be_enabled()
234 ? (plug->is_enabled() ? "enabled" : "disabled")
235 : "n/a")
236 );
237 con.color(COLOR_RESET);
238 }
239
240 return CR_OK;
241 }
242
243 command_result Commands::type(color_ostream& con, Core& core, const std::string& first, const std::vector<std::string>& parts)
244 {

Callers

nothing calls this directly

Calls 10

can_be_enabledMethod · 0.80
findFunction · 0.50
printMethod · 0.45
refreshMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
getStateMethod · 0.45
colorMethod · 0.45
getNameMethod · 0.45
is_enabledMethod · 0.45

Tested by

no test coverage detected