package com.atlassian.stash.internal.scm.git.command.config;

import com.atlassian.stash.internal.scm.git.command.AbstractGitCommandBuilder;
import com.atlassian.bitbucket.scm.Command;
import com.atlassian.bitbucket.scm.git.command.GitScmCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.config.GitConfigUnsetAllBuilder;

import javax.annotation.Nonnull;

/**
 * @since 2.0
 */
public class DefaultGitConfigUnsetAllBuilder
        extends AbstractGitCommandBuilder<GitConfigUnsetAllBuilder>
        implements GitConfigUnsetAllBuilder {

    private final String name;

    public DefaultGitConfigUnsetAllBuilder(GitScmCommandBuilder builder, String name) {
        super(builder);

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

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

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

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