package org.implab.gradle.common.tasks;

import org.gradle.api.DefaultTask;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.Internal;
import org.implab.gradle.common.dsl.RedirectFromSpec;
import org.implab.gradle.common.dsl.RedirectToSpec;

public abstract class ExecuteTask extends DefaultTask  {

    private final RedirectToSpec redirectStderr = new RedirectToSpec();

    private final RedirectToSpec redirectStdout = new RedirectToSpec();

    private final RedirectFromSpec redirectStdin = new RedirectFromSpec();

    @Internal
    public abstract ListProperty<String> getCommandLine();


    /**
     * STDIN redirection, if not specified, no input will be passed to the command
     */
    @Internal
    public RedirectFromSpec getStdin() {
        return redirectStdin;
    }

    /**
     * STDOUT redirection, if not specified, redirected to logger::info
     */
    @Internal
    public RedirectToSpec getStdout() {
        return redirectStdout;
    }

    /**
     * STDERR redirection, if not specified, redirected to logger::error
     */
    @Internal
    public RedirectToSpec getStderr() {
        return redirectStderr;
    }


        /** Appends specified parameters to the command line */
        void commandLine(String... args) {
            getCommandLine().addAll(args);
        }
    
    
}
