From 55338e7481fc1b789463dd3a2f042690d0de86a5 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Mon, 29 Jan 2018 15:43:22 -0800 Subject: [PATCH] Simplify, readd --wait-for-input --- src/command_line.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 4462de9f..2c19bac3 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -74,8 +74,8 @@ bool ShouldDisplayIpcTiming(IpcId id) { REGISTER_IPC_MESSAGE(Ipc_CancelRequest); -void PrintHelp(std::ostream& os) { - os << R"help(cquery is a low-latency C/C++/Objective-C language server. +void PrintHelp() { + std::cout << R"help(cquery is a low-latency C/C++/Objective-C language server. Mode: --clang-sanity-check @@ -100,6 +100,7 @@ Other command line options: Print stdin (requests) and stdout (responses) to stderr --log-file Logging file for diagnostics --log-all-to-stderr Write all log messages to STDERR. + --wait-for-input Wait for an '[Enter]' before exiting --help Print this help information. --ci Prevents tests from prompting the user for input. Used for continuous integration so it can fail faster instead of timing @@ -107,7 +108,6 @@ Other command line options: See more on https://github.com/cquery-project/cquery/wiki )help"; - exit(&os == &std::cout ? 0 : 1); } } // namespace @@ -439,8 +439,10 @@ int main(int argc, char** argv) { std::unordered_map options = ParseOptions(argc, argv); - if (HasOption(options, "-h") || HasOption(options, "--help")) - PrintHelp(std::cout); + if (HasOption(options, "-h") || HasOption(options, "--help")) { + PrintHelp(); + return 0; + } if (!HasOption(options, "--log-all-to-stderr")) loguru::g_stderr_verbosity = loguru::Verbosity_WARNING; @@ -485,7 +487,7 @@ int main(int argc, char** argv) { g_debug = true; language_server = false; if (!RunIndexTests(options["--test-index"], !HasOption(options, "--ci"))) - return -1; + return 1; } if (language_server) { @@ -519,5 +521,10 @@ int main(int argc, char** argv) { &stdout_waiter); } + if (HasOption(options, "--wait-for-input")) { + std::cerr << std::endl << "[Enter] to exit" << std::endl; + getchar(); + } + return 0; }