IGNITE-1498 Added support for -cfg=path command line option.

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

Branch: refs/heads/ignite-gg-10760
Commit: cd6a1d513adab5a24b33a9315bfd083c2f4383ee
Parents: 6187241
Author: Alexey Kuznetsov <akuznet...@apache.org>
Authored: Thu Sep 17 14:33:00 2015 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Thu Sep 17 14:33:00 2015 +0700

----------------------------------------------------------------------
 .../ignite/visor/commands/VisorConsole.scala    | 31 +++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cd6a1d51/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 bcfc6e0..627f795 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
@@ -84,13 +84,14 @@ class VisorConsole {
 
         if (hasArgFlag("?", argLst) || hasArgFlag("help", argLst)) {
             println("Usage:")
-            println(s"    $progName [?]|[{-v}{-np}]|[{-b=<batch commands file 
path>} {-e=command1;command2}]")
+            println(s"    $progName [? | -help]|[{-v}{-np} 
{-cfg=<path>}]|[{-b=<path>} {-e=command1;command2;...}]")
             println("    Where:")
-            println("        ?, /help, -help - show this message.")
-            println("        -v              - verbose mode (quiet by 
default).")
-            println("        -np             - no pause on exit (pause by 
default)")
-            println("        -b              - batch mode with file)")
-            println("        -e              - batch mode with commands)")
+            println("        ?, /help, -help      - show this message.")
+            println("        -v                   - verbose mode (quiet by 
default).")
+            println("        -np                  - no pause on exit (pause by 
default).")
+            println("        -cfg=<path>          - connect with specified 
configuration.")
+            println("        -b=<path>            - batch mode with file.")
+            println("        -e==cmd1;cmd2;...    - batch mode with commands.")
 
             visor.quit()
         }
@@ -99,14 +100,22 @@ class VisorConsole {
     }
 
     protected def buildReader(argLst: ArgList) = {
+        val cfgFile = argValue("cfg", argLst)
         val batchFile = argValue("b", argLst)
         val batchCommand = argValue("e", argLst)
 
+        cfgFile.foreach(cfg => {
+            if (batchFile.isDefined || batchCommand.isDefined) {
+                visor.warn("Options can't contains both -cfg and one of -b or 
-e options.")
+
+                visor.quit()
+            }
+
+            visor.searchCmd("open").foreach(_.withArgs("-cpath=" + cfg))
+        })
+
         if (batchFile.isDefined && batchCommand.isDefined) {
-            visor.warn(
-                "Illegal options can't contains both command file and 
commands",
-                s"Usage: $progName {-b=<batch commands file path>} 
{-e=command1;command2}"
-            )
+            visor.warn("Options can't contains both command file and 
commands.")
 
             visor.quit()
         }
@@ -303,7 +312,7 @@ object VisorConsole extends VisorConsole with App {
     addCommands()
 
     private val argLst = parse(args.mkString(" "))
-    
+
     private val reader = buildReader(argLst)
 
     visor.reader(reader)

Reply via email to