You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by GitBox <gi...@apache.org> on 2018/11/26 13:27:17 UTC

[GitHub] jamesbognar closed pull request #20: Improve config command logic

jamesbognar closed pull request #20: Improve config command logic
URL: https://github.com/apache/juneau/pull/20
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/console/ConfigCommand.java b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/console/ConfigCommand.java
index 6a504a329..57c256945 100644
--- a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/console/ConfigCommand.java
+++ b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/console/ConfigCommand.java
@@ -50,25 +50,33 @@ public String getDescription() {
 	public boolean execute(Scanner in, PrintWriter out, Args args) {
 		Config conf = Microservice.getInstance().getConfig();
 		if (args.size() > 2) {
+			String option = args.getArg(1);
 			String key = args.getArg(2);
-			if (args.getArg(1).equals("get")) {
-				String val = conf.getString(key);
-				if (val == null)
-					out.println(mb.getString("KeyNotFound", key));
-				else
-					out.println(val);
-			}
-			else if (args.getArg(1).equals("set")) {
-				if(args.size() < 3) {
-					out.println(mb.getString("InvalidArguments"));
+			if (option.equals("get")) {
+				// config get <key>
+				if (args.size() == 3) {
+					String val = conf.getString(key);
+					if (val != null)
+						out.println(val);
+					else
+						out.println(mb.getString("KeyNotFound", key));	
+				} else {
+					out.println(mb.getString("TooManyArguments"));
 				}
-				else {
+			} else if (option.equals("set")) {
+				// config set <key> <value>
+				if (args.size() == 4) {
 					conf.set(key, args.getArg(3));
 					out.println(mb.getString("ConfigSet"));
+				} else if (args.size() < 4) {
+					out.println(mb.getString("InvalidArguments"));
+				} else {
+					out.println(mb.getString("TooManyArguments"));
 				}
+			} else {
+				out.println(mb.getString("InvalidArguments"));
 			}
-		}
-		else {
+		} else {
 			out.println(mb.getString("InvalidArguments"));
 		}
 		return false;
diff --git a/juneau-microservice/juneau-microservice-server/src/main/resources/org/apache/juneau/microservice/console/Messages.properties b/juneau-microservice/juneau-microservice-server/src/main/resources/org/apache/juneau/microservice/console/Messages.properties
index c447e1d34..05f0fee95 100644
--- a/juneau-microservice/juneau-microservice-server/src/main/resources/org/apache/juneau/microservice/console/Messages.properties
+++ b/juneau-microservice/juneau-microservice-server/src/main/resources/org/apache/juneau/microservice/console/Messages.properties
@@ -36,5 +36,6 @@ HelpCommand.CommandNotFound = Command not found.
 ConfigCommand.info = Get or set configuration
 ConfigCommand.description = Get configuration value for given key and set (Restart required) for given key and value 
 ConfigCommand.InvalidArguments = Invalid or missing arguments for config command
+ConfigCommand.TooManyArguments = Too many arguments for config command
 ConfigCommand.KeyNotFound = key ''{0}'' is not found in current configuration
 ConfigCommand.ConfigSet = Configuration updated.


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services