test_class.declarator: directory
test_class.modifier: private
test_class.original_string: private Path directory;
test_class.type: Path
test_class.var_name: directory
test_class.file: tf-build-tools/tf-cmd-api/src/test/java/com/deliveredtechnologies/io/CommandLineTest.java
test_class.identifier: CommandLineTest
test_case.body: @Test(expected = InvalidExitValueException.class)
    public void executeThatErrorsOnItsCommandThrowsTheErrorOutput() throws IOException, InterruptedException {
      String errorCommand = "exit 1";
      Executable commandLine = new CommandLine(directory, false, LoggerFactory.getLogger(CommandLine.class));
      commandLine.execute(errorCommand);
    }
test_case.class_method_signature: CommandLineTest.executeThatErrorsOnItsCommandThrowsTheErrorOutput()
test_case.full_signature: @Test(expected = InvalidExitValueException.class) public void executeThatErrorsOnItsCommandThrowsTheErrorOutput()
test_case.identifier: executeThatErrorsOnItsCommandThrowsTheErrorOutput
test_case.invocations: getLogger execute
test_case.modifiers: @Test(expected = InvalidExitValueException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void executeThatErrorsOnItsCommandThrowsTheErrorOutput()
focal_class.declarator: DEFAULT_TIMEOUT = 600000
focal_class.modifier: private static
focal_class.original_string: private static int DEFAULT_TIMEOUT = 600000;
focal_class.type: int
focal_class.var_name: DEFAULT_TIMEOUT
focal_class.declarator: directory
focal_class.modifier: private
focal_class.original_string: private Path directory;
focal_class.type: Path
focal_class.var_name: directory
focal_class.declarator: inheritIO
focal_class.modifier: private
focal_class.original_string: private boolean inheritIO;
focal_class.type: boolean
focal_class.var_name: inheritIO
focal_class.declarator: logger
focal_class.modifier: private
focal_class.original_string: private Logger logger;
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/io/CommandLine.java
focal_class.identifier: CommandLine
focal_class.interfaces: implements Executable
focal_class.class_method_signature: CommandLine.CommandLine(Path directory)
focal_class.full_signature: public  CommandLine(Path directory)
focal_class.identifier: CommandLine
focal_class.modifiers: public
focal_class.parameters: (Path directory)
focal_class.signature:  CommandLine(Path directory)
focal_class.class_method_signature: CommandLine.CommandLine(Path directory, Logger logger)
focal_class.full_signature: public  CommandLine(Path directory, Logger logger)
focal_class.identifier: CommandLine
focal_class.modifiers: public
focal_class.parameters: (Path directory, Logger logger)
focal_class.signature:  CommandLine(Path directory, Logger logger)
focal_class.class_method_signature: CommandLine.CommandLine(Path directory, boolean inheritIO, Logger logger)
focal_class.full_signature: public  CommandLine(Path directory, boolean inheritIO, Logger logger)
focal_class.identifier: CommandLine
focal_class.modifiers: public
focal_class.parameters: (Path directory, boolean inheritIO, Logger logger)
focal_class.signature:  CommandLine(Path directory, boolean inheritIO, Logger logger)
focal_class.class_method_signature: CommandLine.execute(String command, int timeout)
focal_class.full_signature: @Override public String execute(String command, int timeout)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (String command, int timeout)
focal_class.return: String
focal_class.signature: String execute(String command, int timeout)
focal_class.class_method_signature: CommandLine.execute(String command)
focal_class.full_signature: @Override public String execute(String command)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (String command)
focal_class.return: String
focal_class.signature: String execute(String command)
focal_class.class_method_signature: CommandLine.getShell()
focal_class.full_signature: private List<String> getShell()
focal_class.identifier: getShell
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: List<String>
focal_class.signature: List<String> getShell()
focal_class.class_method_signature: CommandLine.setLogger(Logger logger)
focal_class.full_signature: @Override public void setLogger(Logger logger)
focal_class.identifier: setLogger
focal_class.modifiers: @Override public
focal_class.parameters: (Logger logger)
focal_class.return: void
focal_class.signature: void setLogger(Logger logger)
focal_class.class_method_signature: CommandLine.getDirectory()
focal_class.full_signature: public Path getDirectory()
focal_class.identifier: getDirectory
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Path
focal_class.signature: Path getDirectory()
focal_method.body: @Override
    public String execute(String command, int timeout) throws IOException, InterruptedException {
  
      logger.info("*** directory: {} ***", getDirectory().toAbsolutePath());
      logger.info("*** command: {} ***", command);
  
      ProcessExecutor processExecutor = new ProcessExecutor();
  
      List<String> cmd = new ArrayList<>(getShell());
      cmd.add(command);
  
      Optional<String> output;
  
      String [] baseCommand = command.split(" ");
      String baseCommandName = Paths.get(baseCommand[0]).getFileName().toString();
      String loggerName = baseCommand.length >= 2 ? baseCommandName + "-" + baseCommand[1] : baseCommandName;
      try {
        output = Optional.ofNullable(processExecutor.command(cmd)
          .directory(directory.toAbsolutePath().toFile())
          .redirectOutput(Slf4jStream.of(LoggerFactory.getLogger(loggerName)).asInfo())
          .timeout(timeout, TimeUnit.MILLISECONDS)
          .readOutput(true)
          .exitValueNormal()
          .destroyOnExit()
          .execute()
          .outputString());
      } catch (TimeoutException e) {
        logger.error("Processed timed out", e);
        throw new InterruptedException(e.getMessage());
      }
      return output.orElse("");
    }
focal_method.class_method_signature: CommandLine.execute(String command, int timeout)
focal_method.full_signature: @Override public String execute(String command, int timeout)
focal_method.identifier: execute
focal_method.invocations: info toAbsolutePath getDirectory info getShell add split toString getFileName get ofNullable outputString execute destroyOnExit exitValueNormal readOutput timeout redirectOutput directory command toFile toAbsolutePath asInfo of getLogger error getMessage orElse
focal_method.modifiers: @Override public
focal_method.parameters: (String command, int timeout)
focal_method.return: String
focal_method.signature: String execute(String command, int timeout)