package org.implab.gradle.common.exec;

import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;

@NonNullByDefault
public interface PipeBuilder {
    PipeBuilder stdin(RedirectFrom from);

    PipeBuilder stdin(Optional<? extends RedirectFrom> from);

    PipeBuilder stdout(RedirectTo to);

    PipeBuilder stdout(Optional<? extends RedirectTo> to);

    PipeBuilder stderr(RedirectTo to);

    PipeBuilder stderr(Optional<? extends RedirectTo> to);

    default PipeBuilder from(PipeSpec pipeSpec) {
        return stdin(pipeSpec.stdin())
                .stdout(pipeSpec.stdout())
                .stderr(pipeSpec.stderr());
    }

}
