Przeglądaj źródła

Clean up final common parameter check and fix rebase merge issue.

Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>
Anthony Fishbeck 13 lat temu
rodzic
commit
8335b11382

+ 30 - 0
ecl/eclcmd/eclcmd_common.cpp

@@ -217,3 +217,33 @@ StringBuffer &EclObjectParameter::getDescription(StringBuffer &s)
 {
     return s.append(queryTypeName()).append(' ').append(value.get());
 }
+
+eclCmdOptionMatchIndicator EclCmdCommon::matchCommandLineOption(ArgvIterator &iter, bool finalAttempt)
+{
+    bool boolValue;
+    if (iter.matchFlag(boolValue, ECLOPT_VERSION))
+    {
+        fprintf(stdout, "%s\n", BUILD_TAG);
+        return EclCmdOptionCompletion;
+    }
+    if (iter.matchOption(optServer, ECLOPT_SERVER))
+        return EclCmdOptionMatch;
+    if (iter.matchOption(optPort, ECLOPT_PORT))
+        return EclCmdOptionMatch;
+    if (iter.matchOption(optUsername, ECLOPT_USERNAME))
+        return EclCmdOptionMatch;
+    if (iter.matchOption(optPassword, ECLOPT_PASSWORD))
+        return EclCmdOptionMatch;
+    if (finalAttempt)
+        fprintf(stderr, "\n%s option not recognized\n", iter.query());
+    return EclCmdOptionNoMatch;
+}
+
+bool EclCmdCommon::finalizeOptions(IProperties *globals)
+{
+    extractEclCmdOption(optServer, globals, ECLOPT_SERVER_ENV, ECLOPT_SERVER_INI, ECLOPT_SERVER_DEFAULT, NULL);
+    extractEclCmdOption(optPort, globals, ECLOPT_PORT_ENV, ECLOPT_PORT_INI, ECLOPT_PORT_DEFAULT, NULL);
+    extractEclCmdOption(optUsername, globals, ECLOPT_USERNAME_ENV, ECLOPT_USERNAME_INI, NULL, NULL);
+    extractEclCmdOption(optPassword, globals, ECLOPT_PASSWORD_ENV, ECLOPT_PASSWORD_INI, NULL, NULL);
+    return true;
+}

+ 3 - 26
ecl/eclcmd/eclcmd_common.hpp

@@ -103,32 +103,9 @@ public:
     EclCmdCommon()
     {
     }
-    virtual eclCmdOptionMatchIndicator matchCommandLineOption(ArgvIterator &iter)
-    {
-        bool boolValue;
-        if (iter.matchFlag(boolValue, ECLOPT_VERSION))
-        {
-            fprintf(stdout, "%s\n", BUILD_TAG);
-            return EclCmdOptionCompletion;
-        }
-        if (iter.matchOption(optServer, ECLOPT_SERVER))
-            return EclCmdOptionMatch;
-        if (iter.matchOption(optPort, ECLOPT_PORT))
-            return EclCmdOptionMatch;
-        if (iter.matchOption(optUsername, ECLOPT_USERNAME))
-            return EclCmdOptionMatch;
-        if (iter.matchOption(optPassword, ECLOPT_PASSWORD))
-            return EclCmdOptionMatch;
-        return EclCmdOptionNoMatch;
-    }
-    virtual bool finalizeOptions(IProperties *globals)
-    {
-        extractEclCmdOption(optServer, globals, ECLOPT_SERVER_ENV, ECLOPT_SERVER_INI, ECLOPT_SERVER_DEFAULT, NULL);
-        extractEclCmdOption(optPort, globals, ECLOPT_PORT_ENV, ECLOPT_PORT_INI, ECLOPT_PORT_DEFAULT, NULL);
-        extractEclCmdOption(optUsername, globals, ECLOPT_USERNAME_ENV, ECLOPT_USERNAME_INI, NULL, NULL);
-        extractEclCmdOption(optPassword, globals, ECLOPT_PASSWORD_ENV, ECLOPT_PASSWORD_INI, NULL, NULL);
-        return true;
-    }
+    virtual eclCmdOptionMatchIndicator matchCommandLineOption(ArgvIterator &iter, bool finalAttempt=false);
+    virtual bool finalizeOptions(IProperties *globals);
+
     virtual void usage()
     {
         fprintf(stdout,

+ 8 - 54
ecl/eclcmd/eclcmd_core.cpp

@@ -70,21 +70,8 @@ public:
                 continue;
             if (iter.matchOption(optName, ECLOPT_NAME))
                 continue;
-            switch (EclCmdCommon::matchCommandLineOption(iter))
-            {
-                case EclCmdOptionNoMatch:
-                    fprintf(stderr, "\n%s option not recognized\n", arg);
-                    return false;
-                case EclCmdOptionCompletion:
-                    return false;
-                case EclCmdOptionMatch:
-                    break;
-            }
-            else
-            {
-                fprintf(stderr, "\n%s option not recognized\n", arg);
+            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                 return false;
-            }
         }
         return true;
     }
@@ -227,21 +214,8 @@ public:
                 activateSet=true;
                 continue;
             }
-            switch (EclCmdCommon::matchCommandLineOption(iter))
-            {
-                case EclCmdOptionNoMatch:
-                    fprintf(stderr, "\n%s option not recognized\n", arg);
-                    return false;
-                case EclCmdOptionCompletion:
-                    return false;
-                case EclCmdOptionMatch:
-                    break;
-            }
-            else
-            {
-                fprintf(stderr, "\n%s option not recognized\n", arg);
+            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                 return false;
-            }
         }
         return true;
     }
@@ -319,7 +293,6 @@ public:
             return false;
         }
 
-        bool boolValue;
         for (; !iter.done(); iter.next())
         {
             const char *arg = iter.query();
@@ -331,21 +304,12 @@ public:
                     return false;
                 }
                 optQueryId.set(arg);
-            }
-            else if (EclCmdCommon::matchCommandLineOption(iter))
                 continue;
-            else if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
-                continue;
-            else if (iter.matchFlag(boolValue, ECLOPT_VERSION))
-            {
-                fprintf(stdout, "%s\n", BUILD_TAG);
-                return false;
             }
-            else
-            {
-                fprintf(stderr, "\n%s option not recognized\n", arg);
+            if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
+                continue;
+            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                 return false;
-            }
         }
         return true;
     }
@@ -429,7 +393,6 @@ public:
             return false;
         }
 
-        bool boolValue;
         for (; !iter.done(); iter.next())
         {
             const char *arg = iter.query();
@@ -441,21 +404,12 @@ public:
                     return false;
                 }
                 optAlias.set(arg);
-            }
-            else if (EclCmdCommon::matchCommandLineOption(iter))
                 continue;
-            else if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
-                continue;
-            else if (iter.matchFlag(boolValue, ECLOPT_VERSION))
-            {
-                fprintf(stdout, "%s\n", BUILD_TAG);
-                return false;
             }
-            else
-            {
-                fprintf(stderr, "\n%s option not recognized\n", arg);
+            if (iter.matchOption(optQuerySet, ECLOPT_QUERYSET))
+                continue;
+            if (EclCmdCommon::matchCommandLineOption(iter, true)!=EclCmdOptionMatch)
                 return false;
-            }
         }
         return true;
     }