mirror of
https://github.com/matrix-construct/construct
synced 2024-11-16 23:10:54 +01:00
modules/console: Allow lists of module names to mod cmds.
This commit is contained in:
parent
6b4e188682
commit
2b6fd1c985
1 changed files with 36 additions and 25 deletions
|
@ -627,55 +627,66 @@ console_cmd__mod__syms(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__mod__reload(opt &out, const string_view &line)
|
console_cmd__mod__reload(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
const std::string name
|
const auto names
|
||||||
{
|
{
|
||||||
token(line, ' ', 0)
|
tokens<std::vector>(line, ' ')
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!m::modules.erase(name))
|
for(auto it(names.begin()); it != names.end(); ++it)
|
||||||
{
|
{
|
||||||
|
const auto &name{*it};
|
||||||
|
if(m::modules.erase(std::string{name}))
|
||||||
|
out << name << " unloaded." << std::endl;
|
||||||
|
else
|
||||||
out << name << " is not loaded." << std::endl;
|
out << name << " is not loaded." << std::endl;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m::modules.emplace(name, name);
|
for(auto it(names.rbegin()); it != names.rend(); ++it)
|
||||||
out << "reload " << name << std::endl;
|
{
|
||||||
|
const auto &name{*it};
|
||||||
|
if(m::modules.emplace(std::string{name}, name).second)
|
||||||
|
out << name << " loaded." << std::endl;
|
||||||
|
else
|
||||||
|
out << name << " is already loaded." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__mod__load(opt &out, const string_view &line)
|
console_cmd__mod__load(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
const std::string name
|
tokens(line, ' ', [&out]
|
||||||
|
(const string_view &name)
|
||||||
{
|
{
|
||||||
token(line, ' ', 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
if(m::modules.find(name) != end(m::modules))
|
if(m::modules.find(name) != end(m::modules))
|
||||||
{
|
{
|
||||||
out << name << " is already loaded." << std::endl;
|
out << name << " is already loaded." << std::endl;
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m::modules.emplace(name, name);
|
m::modules.emplace(std::string{name}, name);
|
||||||
|
out << name << " loaded." << std::endl;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__mod__unload(opt &out, const string_view &line)
|
console_cmd__mod__unload(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
const std::string name
|
tokens(line, ' ', [&out]
|
||||||
|
(const string_view &name)
|
||||||
{
|
{
|
||||||
token(line, ' ', 0)
|
if(!m::modules.erase(std::string{name}))
|
||||||
};
|
|
||||||
|
|
||||||
if(!m::modules.erase(name))
|
|
||||||
{
|
{
|
||||||
out << name << " is not loaded." << std::endl;
|
out << name << " is not loaded." << std::endl;
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "unloaded " << name << std::endl;
|
out << "unloaded " << name << std::endl;
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue