You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/01/31 11:39:21 UTC

[2/4] tinkerpop git commit: TINKERPOP-1879 More consistently handle the short options with "="

TINKERPOP-1879 More consistently handle the short options with "="


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b251d544
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b251d544
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b251d544

Branch: refs/heads/master
Commit: b251d54460f4d65a48503eb8c446fbd25bc3fcd9
Parents: 352d06e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jan 30 16:04:28 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jan 30 16:04:28 2018 -0500

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/console/Console.groovy    | 11 ++++++++---
 gremlin-console/src/test/python/tests/test_console.py  | 13 +++++--------
 2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b251d544/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index fe9e613..4e54a42 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -526,8 +526,13 @@ class Console {
      * to split the flag from the argument so that it can be evaluated in a consistent way by {@code parseArgs()}.
      */
     private static def normalizeArgs(final List<String> options, final String[] args) {
-        return args.collect{ arg -> options.any{
-            arg.startsWith(it) } ? arg.split("=", 2) : arg
-        }.flatten().toArray()
+        return args.collect{ arg ->
+                // arguments that match -i/-e options should be normalized where long forms need to be split on "="
+                // and short forms need to have the "=" included with the argument
+                if (options.any{ arg.startsWith(it) }) {
+                    return arg.matches("^-[e,i]=.*") ? [arg.substring(0, 2), arg.substring(2)] : arg.split("=", 2)
+                } 
+                return arg
+            }.flatten().toArray()
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b251d544/gremlin-console/src/test/python/tests/test_console.py
----------------------------------------------------------------------
diff --git a/gremlin-console/src/test/python/tests/test_console.py b/gremlin-console/src/test/python/tests/test_console.py
index 88c1a05..3e22929 100644
--- a/gremlin-console/src/test/python/tests/test_console.py
+++ b/gremlin-console/src/test/python/tests/test_console.py
@@ -41,14 +41,6 @@ class TestConsole(object):
         TestConsole._expect_prompt(child)
         TestConsole._close(child)
 
-    def test_just_dash_i_with_equals(self):
-        child = pexpect.spawn(TestConsole.gremlinsh + "-i=x.script")
-        TestConsole._expect_gremlin_header(child)
-        TestConsole._send(child, "x")
-        child.expect("==>2\r\n")
-        TestConsole._expect_prompt(child)
-        TestConsole._close(child)
-
     def test_just_dash_dash_interactive(self):
         child = pexpect.spawn(TestConsole.gremlinsh + "--interactive x.script")
         TestConsole._expect_gremlin_header(child)
@@ -128,6 +120,11 @@ class TestConsole(object):
         child.expect("2\r\n")
         TestConsole._close(child)
 
+    def test_just_dash_e_file_not_found(self):
+        child = pexpect.spawn(TestConsole.gremlinsh + "-e=x-printed.script")
+        child.expect("Gremlin file not found at \[=x-printed.script\]\.\r\n")
+        child.expect(pexpect.EOF)
+
     def test_just_dash_dash_execute(self):
         child = pexpect.spawn(TestConsole.gremlinsh + "--execute x-printed.script")
         child.expect("2\r\n")