You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@fluo.apache.org by GitBox <gi...@apache.org> on 2020/01/15 04:33:59 UTC

[GitHub] [fluo] jkosh44 opened a new issue #1085: Make commands more easily reusable outside of CLI

jkosh44 opened a new issue #1085: Make commands more easily reusable outside of CLI
URL: https://github.com/apache/fluo/issues/1085
 
 
   In Issue #983 some people expressed a desire to be able to reuse commands outside of the CLI, for example in APIs and UIs. PR #1083 helped with this by removing `System.exit` from the commands themselves and restructuring the module so you don't have to call the `main` method on a command to execute it.
   
   The following three issues still make it difficult for the commands to be reusable:
   1. Many of the commands directly print to `System.out` or log to a Logger.
   2. Many of the commands rely on side effects instead of returning a meaningful response (ex: `FluoList`, `FluoStatus`).
   3. There's no way to set the options of a command.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [fluo] jkosh44 edited a comment on issue #1085: Make commands more easily reusable outside of CLI

Posted by GitBox <gi...@apache.org>.
jkosh44 edited a comment 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
   ```java
   @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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [fluo] jkosh44 commented on issue #1085: Make commands more easily reusable outside of CLI

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services