package org.implab.gradle.common.exec;

import org.eclipse.jdt.annotation.NonNullByDefault;

@NonNullByDefault
public interface Shell {

    ShellExec create(CommandSpec spec);

    default ShellTool tool(String executable) {
        return new ShellTool(executable, this);
    }

    /** Creates a new shell to start processes using ProcessBuilder. */
    static Shell system() {
        return spec -> new SystemExecBuilder(spec);
    }

    /** Creates a stub shell which echoes the specified command line. */
    static Shell echo() {
        return spec -> new EchoExecBuilder(spec, false);
    }

    /** Creates a stub shell which echoes the specified command line. */
    static Shell echoStderr() {
        return spec -> new EchoExecBuilder(spec, false);
    }

}
