wgtmac commented on code in PR #3286: URL: https://github.com/apache/avro/pull/3286#discussion_r1912077703
########## lang/c++/impl/avrogencpp.cc: ########## @@ -875,49 +872,104 @@ static string readGuard(const string &filename) { return candidate; } +struct ProgramOptions { + bool helpRequested = false; + bool versionRequested = false; + bool noUnionTypedef = false; + std::string includePrefix = "avro"; + std::string nameSpace; + std::string inputFile; + std::string outputFile; +}; + +static void printUsage() { + std::cout << "Allowed options:\n" + << " -h [ --help ] produce help message\n" + << " -V [ --version ] produce version information\n" + << " -p [ --include-prefix ] arg (=avro) prefix for include headers, - for none, default: avro\n" + << " -U [ --no-union-typedef ] do not generate typedefs for unions in records\n" + << " -n [ --namespace ] arg set namespace for generated code\n" + << " -i [ --input ] arg input file\n" + << " -o [ --output ] arg output file to generate\n"; +} + +static bool parseArgs(int argc, char **argv, ProgramOptions &opts) { + for (int i = 1; i < argc; ++i) { + std::string arg = argv[i]; + + if (arg == "-h" || arg == "--help") { + opts.helpRequested = true; + return true; + } + + if (arg == "-V" || arg == "--version") { Review Comment: `avrogencpp -V -U` prints the version without my change. So I think it is consistent with the original behavior. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@avro.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org