Exemplo n.º 1
0
  @Override
  protected void doExecute(ApplicationService applicationService)
      throws ApplicationServiceException {

    Set<Application> applications = applicationService.getApplications();
    console.printf("%s%10s%n", "State", "Name");
    for (Application curApp : applications) {
      ApplicationStatus appStatus = applicationService.getApplicationStatus(curApp);
      // only show applications that have features (gets rid of repo
      // aggregator 'apps')
      if (!curApp.getFeatures().isEmpty()) {
        console.print("[");
        switch (appStatus.getState()) {
          case ACTIVE:
            console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
            break;
          case FAILED:
            console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
            break;
          case INACTIVE:
            // don't set a color
            break;
          case UNKNOWN:
            console.print(Ansi.ansi().fg(Ansi.Color.YELLOW).toString());
            break;
          default:
            break;
        }
        console.print(StringUtils.rightPad(appStatus.getState().toString(), STATUS_COLUMN_LENGTH));
        console.print(Ansi.ansi().reset().toString());
        console.println("] " + curApp.getName());
      }
    }
    return;
  }