diff options
Diffstat (limited to 'contrib/epee/include')
-rw-r--r-- | contrib/epee/include/console_handler.h | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index 0eff095e1..c6e7c857d 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -251,27 +251,33 @@ namespace epee m_stdin_reader.stop(); } + void print_prompt() + { + if (!m_prompt.empty()) + { + epee::log_space::set_console_color(epee::log_space::console_color_yellow, true); + std::cout << m_prompt; + if (' ' != m_prompt.back()) + std::cout << ' '; + epee::log_space::reset_console_color(); + std::cout.flush(); + } + } + private: template<typename t_cmd_handler> bool run(const std::string& prompt, const std::string& usage, const t_cmd_handler& cmd_handler, std::function<void(void)> exit_handler) { TRY_ENTRY(); bool continue_handle = true; + m_prompt = prompt; while(continue_handle) { if (!m_running) { break; } - if (!prompt.empty()) - { - epee::log_space::set_console_color(epee::log_space::console_color_yellow, true); - std::cout << prompt; - if (' ' != prompt.back()) - std::cout << ' '; - epee::log_space::reset_console_color(); - std::cout.flush(); - } + print_prompt(); std::string command; bool get_line_ret = m_stdin_reader.get_line(command); @@ -313,6 +319,7 @@ namespace epee private: async_stdin_reader m_stdin_reader; std::atomic<bool> m_running = {true}; + std::string m_prompt; }; @@ -447,6 +454,11 @@ namespace epee { return m_console_handler.run(boost::bind(&console_handlers_binder::process_command_str, this, _1), prompt, usage_string, exit_handler); } + + void print_prompt() + { + m_console_handler.print_prompt(); + } }; ///* work around because of broken boost bind */ |