diff options
author | Dennis Cappendijk <dennis.cappendijk@gmail.com> | 2017-05-22 16:21:48 +0200 |
---|---|---|
committer | Dennis Cappendijk <dennis.cappendijk@gmail.com> | 2017-05-22 16:21:48 +0200 |
commit | 3b227611d5c5b216fd323908b0c6c4af19777a52 (patch) | |
tree | b835cdc5d032e161a8345744bca4403c45da936e /src | |
parent | 85466206109ee4cffc32bf7d55b02ca78d7a16fa (diff) | |
download | protobuf-3b227611d5c5b216fd323908b0c6c4af19777a52.tar.gz protobuf-3b227611d5c5b216fd323908b0c6c4af19777a52.tar.bz2 protobuf-3b227611d5c5b216fd323908b0c6c4af19777a52.zip |
show help if protoc is called without any arguments, pre-empts -h and --help to show a useful message instead of just 'Missing input file.'
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/command_line_interface.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 7fcd0083..df03907d 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -1012,6 +1012,12 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) { arguments.push_back(argv[i]); } + // if no arguments are given, show help + if(arguments.empty()) { + PrintHelpText(); + return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. + } + // Iterate through all arguments and parse them. for (int i = 0; i < arguments.size(); ++i) { string name, value; |