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 2015/02/19 17:13:56 UTC

incubator-tinkerpop git commit: Sub-classed Groovysh for the console.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master b9431fde2 -> bf60f9342


Sub-classed Groovysh for the console.

This enabled the ability to override the current posix style parsing of Groovysh in groovy 2.4.x.  Commands are now parsing as they did in 2.3.x.


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

Branch: refs/heads/master
Commit: bf60f9342214a0522fee9d75818c4d752c7b5c71
Parents: b9431fd
Author: Stephen Mallette <sp...@apache.org>
Authored: Thu Feb 19 11:12:35 2015 -0500
Committer: Stephen Mallette <sp...@apache.org>
Committed: Thu Feb 19 11:12:35 2015 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    |  2 +-
 .../gremlin/console/GremlinGroovysh.groovy      | 48 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bf60f934/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 69a0b67..efdabf5 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
@@ -51,7 +51,7 @@ class Console {
     private Iterator tempIterator = Collections.emptyIterator()
 
     private final IO io = new IO(System.in, System.out, System.err)
-    private final Groovysh groovy = new Groovysh()
+    private final Groovysh groovy = new GremlinGroovysh()
 
     public Console(final String initScriptFile) {
         io.out.println()

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bf60f934/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
new file mode 100644
index 0000000..0a37d8c
--- /dev/null
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/GremlinGroovysh.groovy
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.console
+
+import org.codehaus.groovy.tools.shell.Command
+import org.codehaus.groovy.tools.shell.Groovysh
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class GremlinGroovysh extends Groovysh {
+    protected List parseLine(final String line) {
+        assert line != null
+        return line.trim().tokenize()
+    }
+
+    @Override
+    Command findCommand(final String line, final List<String> parsedArgs = null) {
+        def l = line ?: ""
+
+        final List<String> args = parseLine(l)
+        if (args.size() == 0) return null
+
+        def cmd = registry.find(args[0])
+
+        if (cmd != null && args.size() > 1 && parsedArgs != null) {
+            parsedArgs.addAll(args[1..-1])
+        }
+
+        return cmd
+    }
+}