diff --git a/aql2/src/prompt/Prompt.cpp b/aql2/src/prompt/Prompt.cpp index dd9d69f9363c21b286aa6734a1d5b9fd8cd85005..de453fc96f01dfc2741e0f1dedcf3fc2f1964808 100644 --- a/aql2/src/prompt/Prompt.cpp +++ b/aql2/src/prompt/Prompt.cpp @@ -31,7 +31,12 @@ char * Prompt::stripwhite ( char * begin ) { return begin; } -Prompt::Prompt ( cli::Environment environment ) : m_prefix ( "> " ), m_environment ( std::move ( environment ) ) { +Prompt::Prompt ( cli::Environment environment ) : m_prefix ( "> " ), m_history_file ( std::string ( std::getenv ( "HOME" ) ) + "/.aql" ), m_environment ( std::move ( environment ) ) { + read_history ( m_history_file.c_str ( ) ); +} + +Prompt::~Prompt ( ) { + write_history ( m_history_file.c_str ( ) ); } cli::Command::Result Prompt::run ( ) { diff --git a/aql2/src/prompt/Prompt.h b/aql2/src/prompt/Prompt.h index ce99f5c44d801edaf5faf22d7ca2cd3f962eb691..9304076ab8bd4c6918d969d3206a1be0f48bb417 100644 --- a/aql2/src/prompt/Prompt.h +++ b/aql2/src/prompt/Prompt.h @@ -18,6 +18,7 @@ class Prompt { Prompt & operator = ( Prompt && ) = delete; std::string m_prefix; + std::string m_history_file; cli::Environment m_environment; @@ -25,6 +26,7 @@ class Prompt { public: Prompt ( cli::Environment environment ); + ~Prompt ( ); cli::Command::Result run ( ); cli::Command::Result execute_line ( std::string line );