package org.implab.gradle.common.exec;

import java.io.File;
import java.util.Map;
import java.util.Optional;

import org.eclipse.jdt.annotation.NonNullByDefault;

@NonNullByDefault
public interface EnvironmentBuilder {
    EnvironmentBuilder setVariable(String envVar, String value);

    EnvironmentBuilder environment(Map<String, ? extends String> env);

    EnvironmentBuilder unsetVariable(String envVar);

    EnvironmentBuilder workingDirectory(File directory);

    EnvironmentBuilder workingDirectory(Optional<? extends File> directory);

    default EnvironmentBuilder from(EnvironmentSpec environmentSpec) {
        return environment(environmentSpec.environment())
            .workingDirectory(environmentSpec.workingDirectory());
    }
}
