Skip to content

Commit 9283dee

Browse files
committed
feat: Use env variable MGCONSOLE_HISTORY_PATH
1 parent 51bbb3c commit 9283dee

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <algorithm>
2121
#include <cstdio>
22+
#include <functional>
2223
#include <iostream>
2324
#include <optional>
2425
#include <thread>
@@ -91,7 +92,7 @@ DEFINE_bool(csv_doublequote, true,
9192
"If `csv-doublequote` is false, 'csv-escapechar' must be set.");
9293

9394
// history
94-
DEFINE_string(history, "/tmp/.memgraph", "Use the specified directory to save history."); // Use /tmp because in K8s deployments users want to have read-only root filesystem. Folder /home/memgraph is part then of the root fileystem and hence read-only
95+
DEFINE_string(history, "~/.memgraph", "Use the specified directory to save history.");
9596
DEFINE_bool(no_history, false, "Do not save history.");
9697

9798
DEFINE_string(
@@ -188,7 +189,14 @@ int main(int argc, char **argv) {
188189
};
189190

190191
if (console::is_a_tty(STDIN_FILENO)) { // INTERACTIVE
191-
return mode::interactive::Run(bolt_config, FLAGS_history, FLAGS_no_history, FLAGS_verbose_execution_info, csv_opts,
192+
auto const history_file = std::invoke([&]() -> std::string {
193+
if (const char *env_file = std::getenv("MGCONSOLE_HISTORY_PATH")) {
194+
return env_file;
195+
}
196+
return FLAGS_history;
197+
});
198+
199+
return mode::interactive::Run(bolt_config, history_file, FLAGS_no_history, FLAGS_verbose_execution_info, csv_opts,
192200
output_opts);
193201
} else if (FLAGS_import_mode == constants::kParserMode) {
194202
return mode::parsing::Run(FLAGS_collect_parser_stats, FLAGS_print_parser_stats);

0 commit comments

Comments
 (0)