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 DefaultGitConfigRemoveSectionBuilder
        extends AbstractGitProcessBuilder<GitConfigRemoveSectionBuilder>
        implements GitConfigRemoveSectionBuilder {

    private final String name;

    public DefaultGitConfigRemoveSectionBuilder(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("--remove-section").argument(name);
    }

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