You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ff...@apache.org on 2017/07/11 03:14:44 UTC

karaf git commit: [KARAF-5243]add -p option for bin/client

Repository: karaf
Updated Branches:
  refs/heads/master 19990b2af -> e409ee501


[KARAF-5243]add -p option for bin/client


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

Branch: refs/heads/master
Commit: e409ee5018b075be4fc77f94b6bf2bbdf460a25b
Parents: 19990b2
Author: Freeman Fang <fr...@gmail.com>
Authored: Tue Jul 11 11:14:32 2017 +0800
Committer: Freeman Fang <fr...@gmail.com>
Committed: Tue Jul 11 11:14:32 2017 +0800

----------------------------------------------------------------------
 .../java/org/apache/karaf/client/ClientConfig.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e409ee50/client/src/main/java/org/apache/karaf/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/ClientConfig.java b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
index 0bfb64b..20e48a1 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -43,6 +43,7 @@ public class ClientConfig {
     private String keyFile = null;
     private String command;
     private boolean interactiveMode = false;
+    private boolean inputPassword = false;
 
     private TypedProperties configuration;
 
@@ -115,6 +116,16 @@ public class ClientConfig {
                     } else {
                         retryAttempts = Integer.parseInt(args[i]);
                     }
+                    
+                } else if (args[i].equals("-p")) {
+                    if (args.length <= ++i) {
+                        System.err.println("miss the password");
+                        System.exit(1);
+                    } else {
+                        password = args[i];
+                        interactiveMode = false;
+                        inputPassword = true;
+                    }
                 } else if (args[i].equals("-d")) {
                     if (args.length <= ++i) {
                         System.err.println("miss the delay in seconds");
@@ -174,9 +185,9 @@ public class ClientConfig {
                     user = users.iterator().next();
                 }
             }
-            if (interactiveMode) {
+            if (interactiveMode && !inputPassword) {
                 password = null;
-            } else {
+            } else if (!inputPassword) {
                 password = usersCfg.get(user);
                 if (password != null && password.contains(ROLE_DELIMITER)) {
                     password = password.substring(0, password.indexOf(ROLE_DELIMITER));
@@ -191,6 +202,7 @@ public class ClientConfig {
         System.out.println("  -a [port]     specify the port to connect to");
         System.out.println("  -h [host]     specify the host to connect to");
         System.out.println("  -u [user]     specify the user name");
+        System.out.println("  -p [password] specify the password (optional, if not provided, the password is prompted)");
         System.out.println("  --help        shows this help message");
         System.out.println("  -v            raise verbosity");
         System.out.println("  -l            set client logging level. Set to 0 for ERROR logging and up to 4 for TRACE");