mirror of
https://github.com/matrix-construct/construct
synced 2024-09-30 04:38:52 +02:00
modules/console: Add conf diff cmd displaying current values against defaults.
This commit is contained in:
parent
077e953e3b
commit
1f1b3033f9
1 changed files with 50 additions and 0 deletions
|
@ -1409,6 +1409,56 @@ console_cmd__conf__reset(opt &out, const string_view &line)
|
||||||
return true;
|
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
|
// hook
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue