Check --init and remove --wait-for-input

This commit is contained in:
Fangrui Song 2018-01-28 14:05:54 -08:00
parent 1e7727f75a
commit 640d72f85c
2 changed files with 8 additions and 9 deletions

View File

@ -100,7 +100,6 @@ Other command line options:
Print stdin (requests) and stdout (responses) to stderr
--log-file <path> 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
@ -502,8 +501,14 @@ int main(int argc, char** argv) {
<< ")\n";
return 1;
}
if (!reader.IsObject()) {
std::cerr << "--init must be a JSON object\n";
JsonReader json_reader{&reader};
try {
Config config;
Reflect(json_reader, config);
} catch (std::invalid_argument& e) {
std::cerr << "Fail to parse --init "
<< static_cast<JsonReader&>(json_reader).GetPath()
<< ", expected " << e.what() << "\n";
return 1;
}
}
@ -514,10 +519,5 @@ 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;
}

View File

@ -14,7 +14,6 @@
// TODO Cleanup global variables
extern std::string g_init_options;
extern bool g_index_builtin_types;
extern int g_enable_comments;
namespace {