0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 12:48:54 +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 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 string_view &state_key
(const auto &key, const string_view &val, const uint &depth, const uint &pos)
{ {
out << std::setw(2) << depth << " + " << pos param[2]
<< " : " << key << " => " << val };
<< std::endl;
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; return true;
} }