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

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

import javax.annotation.Nonnull;

public class DefaultGitConfigGetAllBuilder
        extends AbstractTypedGitConfigBuilder<GitConfigGetAllBuilder>
        implements GitConfigGetAllBuilder {

    private boolean nullTerminated;

    public DefaultGitConfigGetAllBuilder(GitProcessBuilder builder, String name) {
        super(builder, name);
    }

    @Nonnull
    @Override
    public GitConfigGetAllBuilder nullTerminated(boolean value) {
        nullTerminated = value;

        return self();
    }

    @Override
    protected void applyArguments() {
        super.applyArguments();

        if (nullTerminated) {
            builder.argument("-z");
        }

        builder.argument("--get-all")
                .argument(name);
    }

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