You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2022/01/30 20:08:53 UTC

[avro] branch master updated: AVRO-3330: Avrogen returns success if help requested (#1481)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 888ab68  AVRO-3330: Avrogen returns success if help requested (#1481)
888ab68 is described below

commit 888ab68cb5b15098972ef99558dee903fe7b1e7b
Author: Zoltan Csizmadia <zc...@gmail.com>
AuthorDate: Sun Jan 30 14:08:21 2022 -0600

    AVRO-3330: Avrogen returns success if help requested (#1481)
    
    * AVRO-3330: Avrogen returns success if help requested
    
    * AVRO-3330: Seperate help conditions
    
    Co-authored-by: Zoltan Csizmadia <Cs...@valassis.com>
---
 lang/c++/impl/avrogencpp.cc               |  7 ++++++-
 lang/csharp/src/apache/codegen/AvroGen.cs | 11 +++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lang/c++/impl/avrogencpp.cc b/lang/c++/impl/avrogencpp.cc
index 0b6b35a..c287bbd 100644
--- a/lang/c++/impl/avrogencpp.cc
+++ b/lang/c++/impl/avrogencpp.cc
@@ -817,11 +817,16 @@ int main(int argc, char **argv) {
     po::store(po::parse_command_line(argc, argv, desc), vm);
     po::notify(vm);
 
-    if (vm.count("help") || vm.count(IN_FILE) == 0 || vm.count(OUT_FILE) == 0) {
+    if (vm.count(IN_FILE) == 0 || vm.count(OUT_FILE) == 0) {
         std::cout << desc << std::endl;
         return 1;
     }
 
+    if (vm.count("help")) {
+        std::cout << desc << std::endl;
+        return 0;
+    }
+
     string ns = vm.count(NS) > 0 ? vm[NS].as<string>() : string();
     string outf = vm.count(OUT_FILE) > 0 ? vm[OUT_FILE].as<string>() : string();
     string inf = vm.count(IN_FILE) > 0 ? vm[IN_FILE].as<string>() : string();
diff --git a/lang/csharp/src/apache/codegen/AvroGen.cs b/lang/csharp/src/apache/codegen/AvroGen.cs
index 5f4ffd2..3499117 100644
--- a/lang/csharp/src/apache/codegen/AvroGen.cs
+++ b/lang/csharp/src/apache/codegen/AvroGen.cs
@@ -25,13 +25,20 @@ namespace Avro
     {
         static int Main(string[] args)
         {
-            // Print usage if no arguments provided or help requested
-            if (args.Length == 0 || args[0] == "-h" || args[0] == "--help")
+            // Print usage if no arguments provided
+            if (args.Length == 0)
             {
                 Usage();
                 return 1;
             }
 
+            // Print usage if help requested
+            if (args[0] == "-h" || args[0] == "--help")
+            {
+                Usage();
+                return 0;
+            }
+
             // Parse command line arguments
             bool? isProtocol = null;
             string inputFile = null;