Skip to content

Commit 36af360

Browse files
authored
feat: Allow overriding history file through env variable
2 parents 9b9f174 + 9283dee commit 36af360

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main.cpp

Lines changed: 9 additions & 1 deletion
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>
@@ -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)