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

import com.atlassian.stash.internal.scm.git.command.AbstractGitCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.GitCommand;
import com.atlassian.bitbucket.scm.git.command.GitScmCommandBuilder;
import com.atlassian.bitbucket.scm.git.command.config.GitConfigRemoveSectionBuilder;

import javax.annotation.Nonnull;

/**
 * @since 3.1
 */
public class DefaultGitConfigRemoveSectionBuilder
        extends AbstractGitCommandBuilder<GitConfigRemoveSectionBuilder>
        implements GitConfigRemoveSectionBuilder {

    private final String name;

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

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

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

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

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