Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrintingOutput as alternative to StreamingOutput #81

Open
dblevins opened this issue Feb 20, 2017 · 1 comment
Open

PrintingOutput as alternative to StreamingOutput #81

dblevins opened this issue Feb 20, 2017 · 1 comment

Comments

@dblevins
Copy link
Member

Getting quite tiresome to always do:

    @Command
    public StreamingOutput list() {
        return new StreamingOutput() {
            @Override
            public void write(OutputStream os) throws IOException {
                final PrintStream printStream = new PrintStream(os);
                // use the printStream 
            }
        };
    }

For backwards compatibility we should add a new interface PrintingOutput

package org.tomitribe.crest.api;

import java.io.IOException;
import java.io.PrintStream;

public interface PrintingOutput {
    void write(PrintStream out) throws IOException;
}
@rmannibucau
Copy link
Contributor

rmannibucau commented Feb 20, 2017

@Command
public StreamingOutput list(@Out PrintStream printStream) {
    return new StreamingOutput() {
        @Override
        public void write(OutputStream os) throws IOException {
            // use the printStream 
        }
    };
}

or simply (likely more relevant since we dont have output events and it allows to keep interceptor context vs write(out) which lost it):

@Command
public void list(@Out PrintStream printStream) {
    // use the printStream 
}

?

side note: OutputStream from StreamingOutput is already a PrintStream so you can cast it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants