0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-29 07:18:20 +02:00

modules/console: Add conf diff cmd displaying current values against defaults.

This commit is contained in:
Jason Volk 2019-06-07 04:22:35 -07:00
parent 077e953e3b
commit 1f1b3033f9

View file

@ -1409,6 +1409,56 @@ console_cmd__conf__reset(opt &out, const string_view &line)
return true;
}
bool
console_cmd__conf__diff(opt &out, const string_view &line)
{
const params param{line, " ",
{
"key"
}};
const auto &key
{
param[0]
};
const unique_buffer<mutable_buffer> buf
{
4_KiB
};
out << std::setw(48) << std::left << "NAME"
<< " | " << std::setw(36) << "DEFAULT"
<< " | " << std::setw(36) << "CURRENT"
<< std::endl;
for(const auto &item : conf::items)
{
if(!startswith(item.first, key))
continue;
const json::string &default_
{
item.second->feature.get("default")
};
const auto &val
{
item.second->get(buf)
};
if(val == default_)
continue;
out << std::setw(48) << std::left << item.first
<< " | " << std::setw(36) << default_
<< " | " << std::setw(36) << val
<< std::endl;
}
return true;
}
//
// hook
//