package com.atlassian.bitbucket.mesh.git.builder.config;

import com.atlassian.bitbucket.mesh.git.builder.AbstractGitProcessBuilder;
import com.atlassian.bitbucket.mesh.git.builder.GitProcess;
import com.atlassian.bitbucket.mesh.git.builder.GitProcessBuilder;

import javax.annotation.Nonnull;

public class DefaultGitConfigUnsetBuilder
        extends AbstractGitProcessBuilder<GitConfigUnsetBuilder>
        implements GitConfigUnsetBuilder {

    private final String name;

    public DefaultGitConfigUnsetBuilder(GitProcessBuilder builder, String name) {
        super(builder);

        this.name = requireNonBlank(name, "name");
    }

    @Nonnull
    @Override
    public GitProcess<Void> build() {
        return buildWithLoggingHandler();
    }

    @Override
    protected void applyArguments() {
        builder.argument("--unset").argument(name);
    }

    @Nonnull
    @Override
    protected GitConfigUnsetBuilder self() {
        return this;
    }
}
