0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

construct: Add a console watch cmd.

This commit is contained in:
Jason Volk 2018-12-23 18:39:09 -08:00
parent 3fd61ba361
commit f56488dda2
2 changed files with 35 additions and 0 deletions

View file

@ -195,6 +195,9 @@ try
if(startswith(line, "record"))
return cmd__record();
if(startswith(line, "watch"))
return cmd__watch();
int ret{-1};
if(module) switch((ret = handle_line_bymodule()))
{
@ -357,6 +360,37 @@ construct::console::cmd__record()
return true;
}
bool
construct::console::cmd__watch()
{
const auto delay
{
lex_cast<seconds>(token(this->line, ' ', 1))
};
const string_view &line
{
tokens_after(this->line, ' ', 1)
};
this->line = line;
const log::console_quiet quiet(false); do
{
std::cout << '\n';
handle_line(); try
{
ctx::sleep(delay);
}
catch(const ctx::interrupted &)
{
break;
}
}
while(1);
return true;
}
void
construct::console::wait_input()
{

View file

@ -54,6 +54,7 @@ struct construct::console
void wait_input();
bool cmd__record();
bool cmd__watch();
int handle_line_bymodule();
bool handle_line();
void main();