static CliPrinter fromOutputStream(OutputStream stream) {
        Charset charset = StandardCharsets.UTF_8;
        OutputStreamWriter writer = new OutputStreamWriter(stream, charset);

        return new CliPrinter() {
            @Override
            public CliPrinter append(char c) {
                try {
                    writer.append(c);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
                return this;
            }

            @Override
            public CliPrinter append(CharSequence csq) {
                try {
                    writer.append(csq);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
                return this;
            }

            @Override
            public CliPrinter append(CharSequence csq, int start, int end) {
                try {
                    writer.append(csq, start, end);
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
                return this;
            }

            @Override
            public void flush() {
                try {
                    writer.flush();
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
        };
    }
Create a new CliPrinter from an OutputStream.

@param stream OutputStream to write to.
@return Returns the created CliPrinter.
smithy-cli/src/main/java/software/amazon/smithy/cli/CliPrinter.java