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 DefaultGitConfigUnsetAllBuilder
        extends AbstractGitProcessBuilder<GitConfigUnsetAllBuilder>
        implements GitConfigUnsetAllBuilder {

    private final String name;

    public DefaultGitConfigUnsetAllBuilder(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-all").argument(name);
    }

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