plug: Include deleted plugins in full list

develop
lethosor 2015-08-14 19:32:41 -04:00
parent 6aa39a6681
commit a5f15b279c
3 changed files with 20 additions and 8 deletions

@ -815,16 +815,14 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, v
const char *row_format = "%25s %10s %4i\n"; const char *row_format = "%25s %10s %4i\n";
con.print(header_format, "Name", "State", "Cmds"); con.print(header_format, "Name", "State", "Cmds");
vector<string> plugins; plug_mgr->refresh();
if (parts.size()) for (auto it = plug_mgr->begin(); it != plug_mgr->end(); ++it)
plugins = parts;
else
plugins = plug_mgr->listPlugins();
for (auto f = plugins.begin(); f != plugins.end(); ++f)
{ {
const Plugin * plug = plug_mgr->getPluginByName(*f); const Plugin * plug = it->second;
if (!plug) if (!plug)
continue; continue;
if (parts.size() && std::find(parts.begin(), parts.end(), plug->getName()) == parts.end())
continue;
color_value color; color_value color;
switch (plug->getState()) switch (plug->getState())
{ {
@ -847,7 +845,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, v
} }
con.color(color); con.color(color);
con.print(row_format, con.print(row_format,
f->c_str(), plug->getName().c_str(),
Plugin::getStateDescription(plug->getState()), Plugin::getStateDescription(plug->getState()),
plug->size() plug->size()
); );

@ -851,6 +851,17 @@ vector<string> PluginManager::listPlugins()
return results; return results;
} }
void PluginManager::refresh()
{
MUTEX_GUARD(plugin_mutex);
auto files = listPlugins();
for (auto f = files.begin(); f != files.end(); ++f)
{
if (!(*this)[*f])
addPlugin(*f);
}
}
bool PluginManager::load (const string &name) bool PluginManager::load (const string &name)
{ {
MUTEX_GUARD(plugin_mutex); MUTEX_GUARD(plugin_mutex);

@ -261,7 +261,10 @@ namespace DFHack
void unregisterCommands( Plugin * p ); void unregisterCommands( Plugin * p );
// PUBLIC METHODS // PUBLIC METHODS
public: public:
// list names of all plugins present in hack/plugins
std::vector<std::string> listPlugins(); std::vector<std::string> listPlugins();
// create Plugin instances for any plugins in hack/plugins that aren't present in all_plugins
void refresh();
bool load (const std::string &name); bool load (const std::string &name);
bool loadAll(); bool loadAll();