package org.implab.gradle.common.exec.tasks;

import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Internal;
import org.implab.gradle.common.exec.dsl.TaskCommandSpecMixin;
import org.implab.gradle.common.exec.model.CommandSpec;
import org.implab.gradle.common.exec.runtime.Shell;
import org.implab.gradle.common.exec.runtime.ShellExec;

public abstract class ShellExecTask
        extends AbstractShellExecTask
        implements TaskCommandSpecMixin {

    @Internal
    public abstract Property<Shell> getShell();

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


    @Override
    protected ShellExec execBuilder() {
        return getShell().get()
                .create(CommandSpec.builder()
                        .commandLine(getCommandLine().get())
                        .build());
    }

}
