Gerrit0 commented on code in PR #3286:
URL: https://github.com/apache/avro/pull/3286#discussion_r1910335533


##########
lang/c++/impl/avrogencpp.cc:
##########
@@ -875,49 +872,97 @@ 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") {
+            opts.versionRequested = true;
+            return true;
+        }
+
+        if (arg == "-U" || arg == "--no-union-typedef") {
+            opts.noUnionTypedef = true;
+            continue;
+        }
+
+        // Options that require a value
+        if (i + 1 >= argc) {

Review Comment:
   This is unfortunate as providing an unknown option at the end of the 
argument list will produce this error rather than unknown option. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to