public int runCommand(final String command) {
    int errorCode = NO_ERROR;

    RemoteServerSpecificCommand.validateClient(terminal.writer(), restClient);
    try {
      // Commands executed by the '-e' parameter do not need to execute specific CLI
      // commands. For RUN SCRIPT commands, users can use the '-f' command parameter.
      handleLine(command);
    } catch (final EndOfFileException exception) {
      // Ignore - only used by runInteractively() to exit the CLI
    } catch (final Exception exception) {
      errorCode = ERROR;
      LOGGER.error("An error occurred while running a command. Error = "
          + exception.getMessage(), exception);

      terminal.printError(ErrorMessageUtil.buildErrorMessage(exception),
          exception.toString());
    }

    terminal.flush();

    return errorCode;
  }
@Test
  public void shouldSubstituteVariablesOnRunCommand()  {
    // Given:
    final StringBuilder builder = new StringBuilder();
    builder.append("SET '" + KsqlConfig.KSQL_VARIABLE_SUBSTITUTION_ENABLE + "' = 'true';");
    builder.append("DEFINE var = '" + ORDER_DATA_PROVIDER.sourceName() + "';");
    builder.append("CREATE STREAM shouldRunCommand AS SELECT * FROM ${var};");

    // When:
    localCli.runCommand(builder.toString());

    // Then:
    assertThat(terminal.getOutputString(),
        containsString("Created query with ID CSAS_SHOULDRUNCOMMAND"));
  }