Print no result line if empty.result.indicator is empty string.

This seems like a better use of the empty string setting than to actually just 
print an empty string line.


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

Branch: refs/heads/TINKERPOP-1442-master
Commit: 6599159bb861fda3464f2004fc2512bf85ca40c9
Parents: 687ae74
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 15 12:30:04 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Sep 15 12:30:04 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                               |  1 +
 docs/src/reference/gremlin-applications.asciidoc |  3 ++-
 .../tinkerpop/gremlin/console/Console.groovy     | 19 ++++++++++++++-----
 3 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6599159b/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 3b1e4b6..15e1bb2 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,7 @@ TinkerPop 3.2.3 (Release Date: NOT OFFICIALLY RELEASED YET)
 * `TraversalRing` returns a `null` if it does not contain traversals 
(previously `IdentityTraversal`).
 * Fixed a `JavaTranslator` bug where `Bytecode` instructions were being 
mutated during translation.
 * Added `Path` to Gremlin-Python with respective GraphSON 2.0 deserializer.
+* If `empty.result.indicator` is set to an empty string, then no "result line" 
is printed in the console.
 * VertexPrograms can now declare traverser requirements, e.g. to have access 
to the path when used with `.program()`.
 * New build options for `gremlin-python` where `-DglvPython` is no longer 
required.
 * Added missing `InetAddress` to GraphSON extension module.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6599159b/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc 
b/docs/src/reference/gremlin-applications.asciidoc
index 1a0fd16..13ac6ff 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -173,7 +173,8 @@ Preferences are set with `:set name value`.  Values can 
contain spaces when quot
 |result.prompt.color | colors | Color of the result prompt.
 |input.prompt | string | Text of the input prompt.
 |result.prompt | string | Text of the result prompt.
-|empty.result.indicator | string | Text of the void/no results indicator.
+|empty.result.indicator | string | Text of the void/no results indicator - 
setting to empty string (i.e. "" at the
+command line) will print no result line in these cases.
 |=========================================================
 
 Colors can contain a comma-separated combination of 1 each of foreground, 
background, and attribute.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6599159b/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 eeda56d..19ae3c4 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
@@ -199,10 +199,7 @@ class Console {
             if (this.tempIterator.hasNext()) {
                 int counter = 0;
                 while (this.tempIterator.hasNext() && 
(Preferences.maxIteration == -1 || counter < Preferences.maxIteration)) {
-                    final Object object = this.tempIterator.next()
-                    String prompt = 
Colorizer.render(Preferences.resultPromptColor, buildResultPrompt())
-                    String colorizedResult = colorizeResult(object)
-                    io.out.println(prompt + ((null == object) ? 
Preferences.emptyResult : colorizedResult))
+                    printResult(tempIterator.next())
                     counter++;
                 }
                 if (this.tempIterator.hasNext())
@@ -250,7 +247,7 @@ class Console {
                         
io.out.println(Colorizer.render(Preferences.resultPromptColor,(buildResultPrompt()
 + result.prettyPrint(width < 20 ? 80 : width))))
                         return null
                     } else {
-                        
io.out.println(Colorizer.render(Preferences.resultPromptColor,buildResultPrompt()).toString()
 + ((null == result) ? Preferences.emptyResult : colorizeResult(result)))
+                        printResult(result)
                         return null
                     }
                 } catch (final Exception e) {
@@ -261,6 +258,18 @@ class Console {
         }
     }
 
+    def printResult(def object) {
+        final String prompt = Colorizer.render(Preferences.resultPromptColor, 
buildResultPrompt())
+        // if preference is set to empty string then don't print any result
+        if (object != null) {
+            io.out.println(prompt + colorizeResult(object))
+        } else {
+            if (!Preferences.emptyResult.isEmpty()) {
+                io.out.println(prompt + Preferences.emptyResult)
+            }
+        }
+    }
+
     def colorizeResult = { object ->
         if (object instanceof Vertex) {
             return Colorizer.render(Preferences.vertexColor, object.toString())

Reply via email to