clebertsuconic commented on code in PR #4565:
URL: https://github.com/apache/activemq-artemis/pull/4565#discussion_r1276523807


##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java:
##########
@@ -194,62 +186,102 @@ public static Object execute(boolean inputEnabled, 
boolean useSystemOut, File ar
     * Useful on test cases
     */
    private static Object internalExecute(File artemisHome, File 
artemisInstance, File etcFolder, String[] args) throws Exception {
-      return internalExecute(artemisHome, artemisInstance, etcFolder, args, 
ActionContext.system());
+      return internalExecute(artemisHome, artemisInstance, etcFolder, args, 
new ActionContext());
    }
 
    public static Object internalExecute(File artemisHome, File 
artemisInstance, File etcFolder, String[] args, ActionContext context) throws 
Exception {
-      Action action = builder(artemisInstance).build().parse(args);
-      action.setHomeValues(artemisHome, artemisInstance, etcFolder);
+      boolean isInstance = artemisInstance != null || 
System.getProperty("artemis.instance") != null;
+      CommandLine commandLine = buildCommand(isInstance, !isInstance);
+
+      Object userObject = parseAction(commandLine, args);
+      if (userObject instanceof Action) {
+         Action action = (Action) userObject;
+         action.setHomeValues(artemisHome, artemisInstance, etcFolder);
+         if (action.isVerbose()) {
+            context.out.print("Executing " + action.getClass().getName() + " 
");
+            for (String arg : args) {
+               context.out.print(arg + " ");
+            }
+            context.out.println();
+            context.out.println("Home::" + action.getBrokerHome() + ", 
Instance::" + action.getBrokerInstance());
+         }
 
-      if (action.isVerbose()) {
-         context.out.print("Executing " + action.getClass().getName() + " ");
-         for (String arg : args) {
-            context.out.print(arg + " ");
+         return action.execute(context);
+      } else {
+         if (userObject instanceof Runnable) {
+            ((Runnable) userObject).run();
+         }

Review Comment:
   we shouldn't really add anything to do the CommandLine that's not a Runnable 
or an Action. But I will add a check.
   
   That should prevent future devs from making a mistake.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to