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:
parent
3fd61ba361
commit
f56488dda2
2 changed files with 35 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue