public static int runCommand(
            List<String> args,
            Path directory,
            InputStream input,
            Appendable output,
            Map<String, String> env
    ) {
        ProcessBuilder processBuilder = new ProcessBuilder(args)
                .directory(Objects.requireNonNull(directory.toFile(), "Process directory cannot be null"))
                .redirectErrorStream(true);
        processBuilder.environment().putAll(env);

        try {
            Process process = processBuilder.start();

            if (input != null) {
                OutputStream outputStream = process.getOutputStream();
                copyInputToOutput(input, outputStream);
                quietlyCloseStream(args, outputStream);
            }

            try (BufferedReader bufferedStdoutReader = new BufferedReader(
                    new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
                String line;
                while ((line = bufferedStdoutReader.readLine()) != null) {
                    output.append(line).append(System.lineSeparator());
                }
            }

            return process.waitFor();
        } catch (InterruptedException | IOException e) {
            throw new RuntimeException(e);
        }
    }
Helper to run a process.

<p>stderr is redirected to stdout when writing to {@code output} This method <em>does not</em> throw when a
non-zero exit code is encountered. For any more complex use cases, use {@link ProcessBuilder} directly.

@param args      List containing the program and the arguments.
@param directory Directory to use as the working directory.
@param input     Data to write to the stdin of the process. Use {@code null} to send no input.
@param output    Sink destination for lines from stdout and stderr of the process.
@param env       Environment variables to set, possibly overriding specific inherited variables.
@return          Returns the exit code of the process.
smithy-utils/src/main/java/software/amazon/smithy/utils/IoUtils.java