예제 #1
0
  /**
   * The client should not parse the command line by itself, it needs the server to validate it.
   * Hence, the client will have to send incomplete command lines to the server on every keystroke
   * for validation. The server will reply with either a syntax highlight, help message, completion
   * information etc.
   *
   * @return
   */
  public void handleCommandLineInvocation(PbTopLevel topLevelMsgRcv) {
    CommandLineInvocation userAction =
        CommandLineInvocation.newFromProtoBuf(topLevelMsgRcv.getUserAction());
    if (userAction.whatWasinvoked == UserRequestedActionKind.EXECUTE) {
      List<UnResolvedCommandChain> parsedScript =
          commandLineParser.parseUserEditedCommand(userAction);
      List<ResolvedCommandChain> resolvedCmdChains = envVariableResolver.resolve(parsedScript);
      if (resolvedCmdChains.size() != 1) {
        log.error("We do not support multiple tasks yet"); // TODO
      }

      ResolvedCommandChain cmdChain = resolvedCmdChains.get(0);
      cmdChain.setTaskId(getSessionModel().getNextTaskId());
      TaskCreatedStatus taskCreated =
          new TaskCreatedStatus(
              cmdChain.getTaskId(), topLevelMsgRcv.getRequestId(), cmdChain.getUserEditedCommand());
      serverSideSessionModel.onUpstreamTaskCreated(taskCreated);
      executeTaskSync(cmdChain);
    } else if (userAction.whatWasinvoked == UserRequestedActionKind.AUTO_COMPLETE) {
      log.error(userAction.whatWasinvoked + " not implemented.");
    } else {
      log.error(userAction.whatWasinvoked + " not implemented.");
    }
  }
예제 #2
0
 public void executeTaskSync(ResolvedCommandChain commandchain) {
   log.info("executeTaskSync " + commandchain);
   PipelineExecutor executor =
       new PipelineExecutor(ServerSideShellSession.this, commandchain.getTaskId());
   executor.execute(commandchain);
 }