Examples of JLineShellComponent


Examples of org.springframework.shell.core.JLineShellComponent

  public ExitShellRequest run() {

    String[] commandsToExecuteAndThenQuit = commandLine.getShellCommandsToExecute();
    // The shell is used
    JLineShellComponent shell = ctx.getBean("shell", JLineShellComponent.class);
    ExitShellRequest exitShellRequest;

    if (null != commandsToExecuteAndThenQuit) {
      boolean successful = false;
      exitShellRequest = ExitShellRequest.FATAL_EXIT;

      for (String cmd : commandsToExecuteAndThenQuit) {
        successful = shell.executeCommand(cmd).isSuccess();
        if (!successful)
          break;
      }

      // if all commands were successful, set the normal exit status
      if (successful) {
        exitShellRequest = ExitShellRequest.NORMAL_EXIT;
      }
    }
    else {
      shell.start();
      shell.promptLoop();
      exitShellRequest = shell.getExitShellRequest();
      if (exitShellRequest == null) {
        // shouldn't really happen, but we'll fallback to this anyway
        exitShellRequest = ExitShellRequest.NORMAL_EXIT;
      }
      shell.waitForComplete();
    }

    ctx.close();
    sw.stop();
    if (shell.isDevelopmentMode()) {
      System.out.println("Total execution time: " + sw.getLastTaskTimeMillis() + " ms");
    }
    return exitShellRequest;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.