ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [10/20] incubator-ignite git commit: # ignite-185 Append exit in batch mode.
Date Tue, 10 Mar 2015 06:41:56 GMT
# ignite-185 Append exit in batch mode.


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

Branch: refs/heads/ignite-141-2
Commit: e9356ab06e53a147cb472f3113f2bfaddfec9402
Parents: 25cafd4
Author: anovikov <anovikov@gridgain.com>
Authored: Wed Mar 4 15:51:33 2015 +0700
Committer: anovikov <anovikov@gridgain.com>
Committed: Wed Mar 4 15:51:33 2015 +0700

----------------------------------------------------------------------
 .../ignite/visor/commands/VisorConsole.scala    | 30 +++++++++++---------
 1 file changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e9356ab0/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
index 66cbe3e..3cf6619 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
@@ -17,17 +17,18 @@
 
 package org.apache.ignite.visor.commands
 
-import java.awt.Image
-import java.io._
-import java.text.SimpleDateFormat
-import java.util
-import javax.swing.ImageIcon
-
 import org.apache.ignite.internal.IgniteVersionUtils._
 import org.apache.ignite.internal.util.scala.impl
 import org.apache.ignite.internal.util.{IgniteUtils => U}
 import org.apache.ignite.startup.cmdline.AboutDialog
 
+import javax.swing.ImageIcon
+import java._
+import java.awt.Image
+import java.io._
+import java.text.SimpleDateFormat
+import java.util._
+
 // Built-in commands.
 // Note the importing of implicit conversions.
 import org.apache.ignite.visor.commands.ack.VisorAckCommand
@@ -117,7 +118,7 @@ object VisorConsole extends App {
         visor.quit()
     }
 
-    var inputStream: InputStream = new FileInputStream(FileDescriptor.in)
+    var batchStream: Option[InputStream] = None
 
     batchFile.foreach(name => {
         val f = U.resolveIgnitePath(name)
@@ -131,16 +132,19 @@ object VisorConsole extends App {
             visor.quit()
         }
 
-        inputStream = new FileInputStream(f)
+        batchStream = Some(new FileInputStream(f))
     })
 
-    batchCommand.foreach(commands => {
-        val ended = if (commands.endsWith(";")) commands else commands + ";"
+    batchCommand.foreach(commands =>
+        batchStream = Some(new ByteArrayInputStream(commands.replaceAll(";", "\n").getBytes("UTF-8"))))
 
-        val input = (if (ended.endsWith("exit;")) ended else ended + "exit;").replace(";",
"\n")
+    val inputStream = batchStream match {
+        case Some(stream) =>
+            new SequenceInputStream(Collections.enumeration(util.Arrays.asList(stream,
+                new ByteArrayInputStream("\nquit\n".getBytes("UTF-8")))))
 
-        inputStream = new ByteArrayInputStream(input.getBytes("UTF-8"))
-    })
+        case None => new FileInputStream(FileDescriptor.in)
+    }
 
     private val reader = new ConsoleReader(inputStream, System.out, null, null)
 


Mime
View raw message