mirror of
https://github.com/matrix-construct/construct
synced 2024-10-01 21:28:53 +02:00
modules/console: Rename exec cmd to eval; add eval base cmd.
This commit is contained in:
parent
16239f5e0b
commit
f557f26322
1 changed files with 50 additions and 10 deletions
|
@ -327,15 +327,14 @@ console_command_derived(opt &out, const string_view &line)
|
||||||
// Command by JSON
|
// Command by JSON
|
||||||
//
|
//
|
||||||
|
|
||||||
bool console_cmd__exec__event(const json::object &);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_json(const json::object &object)
|
console_json(const json::object &object)
|
||||||
{
|
{
|
||||||
if(!object.has("type"))
|
if(!object.has("type"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return console_cmd__exec__event(object);
|
//return console_cmd__exec__event(object);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1443,25 +1442,66 @@ console_cmd__commit(opt &out, const string_view &line)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// exec
|
// eval
|
||||||
//
|
//
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__exec__event(const json::object &event)
|
console_cmd__eval(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
m::vm::opts opts;
|
const params param{line, " ",
|
||||||
opts.verify = false;
|
|
||||||
m::vm::eval eval
|
|
||||||
{
|
{
|
||||||
opts
|
"event_id", "opts",
|
||||||
|
}};
|
||||||
|
|
||||||
|
const m::event::id &event_id
|
||||||
|
{
|
||||||
|
param.at(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto &args
|
||||||
|
{
|
||||||
|
param[1]
|
||||||
|
};
|
||||||
|
|
||||||
|
const unique_buffer<mutable_buffer> buf
|
||||||
|
{
|
||||||
|
64_KiB
|
||||||
|
};
|
||||||
|
|
||||||
|
const m::event event
|
||||||
|
{
|
||||||
|
event_id, buf
|
||||||
|
};
|
||||||
|
|
||||||
|
m::vm::opts opts;
|
||||||
|
opts.errorlog = 0;
|
||||||
|
opts.warnlog = 0;
|
||||||
|
opts.nothrows = 0;
|
||||||
|
opts.non_conform |= m::event::conforms::MISSING_PREV_STATE;
|
||||||
|
|
||||||
|
tokens(args, ' ', [&opts](const auto &arg)
|
||||||
|
{
|
||||||
|
switch(hash(arg))
|
||||||
|
{
|
||||||
|
case "replay"_:
|
||||||
|
opts.replays = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "noverify"_:
|
||||||
|
opts.verify = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
m::vm::eval eval{opts};
|
||||||
|
out << pretty(event) << std::endl;
|
||||||
eval(event);
|
eval(event);
|
||||||
|
out << "done" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__exec__file(opt &out, const string_view &line)
|
console_cmd__eval__file(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
const params token{line, " ",
|
const params token{line, " ",
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue