jkosh44 commented on issue #1085: Make commands more easily reusable outside of CLI URL: https://github.com/apache/fluo/issues/1085#issuecomment-574491855 Since the original issue, #983, is over 2 years old I thought this issue warranted a discussion to see if it's something people still want and if people agree with my proposed solution. For 1 and 2, we can add a public method to the command classes that returns some type of data object (or primitive if applicable). Not all commands would need this additional method. `execute()` can call this method and do any necessary printing. APIs and UIs can use the public method. For example `FluoStatus` could look like this ``` @Parameters(commandNames = "status", commandDescription = "Prints status of Fluo application for <app>") public class FluoStatus extends AppCommand { public enum AppStatus { NOT_FOUND, RUNNING, STOPPED } @Override public void execute() throws FluoCommandException { AppStatus appStatus = status(); System.out.println(appStatus); } public AppStatus status() { FluoConfiguration config = getConfig(); try (FluoAdminImpl admin = new FluoAdminImpl(config)) { if (!admin.zookeeperInitialized()) { return AppStatus.NOT_FOUND; } else if (admin.applicationRunning()) { return AppStatus.RUNNING; } else { return AppStatus.STOPPED; } } } } ``` `FluoWait` and `FluoInit` will probably be a little tricky, especially since `FluoInit` can read input from `System.in`. For 3 we can simply add setter methods for all the options.
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
