diff --git a/construct/console.cc b/construct/console.cc index af46fc63a..e5590672f 100644 --- a/construct/console.cc +++ b/construct/console.cc @@ -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(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() { diff --git a/construct/construct.h b/construct/construct.h index 15df909ff..a40625452 100644 --- a/construct/construct.h +++ b/construct/construct.h @@ -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();