Skip to content

Commit 3086c3f

Browse files
committed
feat: Use env variable MGCONSOLE_HISTORY_PATH
1 parent 51bbb3c commit 3086c3f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/main.cpp

Lines changed: 14 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,11 @@ 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(
96+
history, "~/.memgraph",
97+
"Use the specified directory to save history."); // Use /tmp because in K8s deployments users want to have
98+
// read-only root filesystem. Folder /home/memgraph is part then
99+
// of the root fileystem and hence read-only
95100
DEFINE_bool(no_history, false, "Do not save history.");
96101

97102
DEFINE_string(
@@ -188,7 +193,14 @@ int main(int argc, char **argv) {
188193
};
189194

190195
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,
196+
auto const history_file = std::invoke([&]() -> std::string {
197+
if (const char *env_file = std::getenv("MGCONSOLE_HISTORY_PATH")) {
198+
return env_file;
199+
}
200+
return FLAGS_history;
201+
});
202+
203+
return mode::interactive::Run(bolt_config, history_file, FLAGS_no_history, FLAGS_verbose_execution_info, csv_opts,
192204
output_opts);
193205
} else if (FLAGS_import_mode == constants::kParserMode) {
194206
return mode::parsing::Run(FLAGS_collect_parser_stats, FLAGS_print_parser_stats);

0 commit comments

Comments
 (0)