Add support for -h to show help in addition to --help (#682)

This commit is contained in:
Tyler Neely 2022-12-07 16:51:32 +01:00 committed by GitHub
parent c529d52664
commit 7d6a5e5b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -134,6 +134,10 @@ std::optional<Enum> 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.

View File

@ -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]