diff --git a/src/memgraph.cpp b/src/memgraph.cpp index c1a245a4c..bf873f5fb 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -134,6 +134,10 @@ std::optional StringToEnum(const auto &value, const auto &mappings) { } } // namespace +// Short help flag. +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +DEFINE_HIDDEN_bool(h, false, "Print usage and exit."); + // Bolt server flags. DEFINE_string(bolt_address, "0.0.0.0", "IP address on which the Bolt server should listen."); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) @@ -687,6 +691,11 @@ int main(int argc, char **argv) { LoadConfig("memgraph"); gflags::ParseCommandLineFlags(&argc, &argv, true); + if (FLAGS_h) { + gflags::ShowUsageWithFlags(argv[0]); + exit(1); + } + InitializeLogger(); // Unhandled exception handler init. diff --git a/tests/e2e/configuration/configuration_check.py b/tests/e2e/configuration/configuration_check.py index 82f9cb83a..b0ee8ded3 100644 --- a/tests/e2e/configuration/configuration_check.py +++ b/tests/e2e/configuration/configuration_check.py @@ -10,10 +10,10 @@ # licenses/APL.txt. import sys -import mgclient -import pytest import default_config +import mgclient +import pytest def test_does_default_config_match(): @@ -24,7 +24,15 @@ def test_does_default_config_match(): cursor.execute("SHOW CONFIG") config = cursor.fetchall() - assert len(config) == len(default_config.startup_config_dict) + define_msg = """ + If this test fails after adding a new DEFINE_* flag, + you should decide whether your new flag needs to be + returned in the SHOW CONFIG command. If not, please + use the DEFINE_HIDDEN_* macro instead of DEFINE_* to + prevent SHOW CONFIG from returning it. + """ + + assert len(config) == len(default_config.startup_config_dict), define_msg for flag in config: flag_name = flag[0]