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

modules/console: Fix the state dfs cmd rot.

This commit is contained in:
Jason Volk 2018-04-26 20:55:47 -07:00
parent 4c2f90273a
commit 412c12fd69

View file

@ -2182,28 +2182,36 @@ console_cmd__state__get(opt &out, const string_view &line)
}
bool
console_cmd__state__dfs(opt &out, const string_view &line)
console_cmd__state__find(opt &out, const string_view &line)
{
const string_view arg
const params param{line, " ",
{
token(line, ' ', 0)
"root", "[type]" "[state_key]"
}};
const string_view &root
{
param.at(0)
};
const string_view root
const string_view &type
{
arg
param[1]
};
m::state::dfs(root, [&out]
(const auto &key, const string_view &val, const uint &depth, const uint &pos)
const string_view &state_key
{
out << std::setw(2) << depth << " + " << pos
<< " : " << key << " => " << val
<< std::endl;
param[2]
};
return true;
});
const auto closure{[&out]
(const auto &key, const string_view &val)
{
out << key << " => " << val << std::endl;
return false;
}};
m::state::test(root, type, state_key, closure);
return true;
}