<commit_before>package org.jenkinsci.plugins.spoontrigger.commands.turbo;

import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
import hudson.util.ArgumentListBuilder;
import org.jenkinsci.plugins.spoontrigger.commands.CommandDriver;
import org.jenkinsci.plugins.spoontrigger.commands.FilterOutputCommand;

import java.util.Collection;
import java.util.regex.Pattern;

public class ConfigCommand extends FilterOutputCommand {

    private static final Pattern HUB_URL_PATTERN = Pattern.compile("^Hub server:\\s+(?<hubUrl>\\S+)$");


    private Optional<String> hub = Optional.absent();

    public Optional<String> getHub() {
        return hub;
    }

    ConfigCommand(ArgumentListBuilder argumentList) {
        super(argumentList);
    }

    @Override
    public void run(CommandDriver client) throws IllegalStateException {
        super.run(client);

        Collection<String> patterns = findInOutput(HUB_URL_PATTERN);
        if (patterns.size() > 0) {
            String hubUrl = Iterables.getLast(patterns);
            hub = Optional.of(hubUrl);
        }
    }

    public static CommandBuilder builder() {
        return new CommandBuilder();
    }

    public static class CommandBuilder {
        private Optional<Boolean> reset = Optional.absent();
        private Optional<String> hub = Optional.absent();

        public CommandBuilder reset(boolean value) {
            this.reset = Optional.of(value);
            return this;
        }

        public CommandBuilder hub(String hubUrl) {
            this.hub = Optional.of(hubUrl);
            return this;
        }

        public ConfigCommand build() {
            ArgumentListBuilder buildArgs = new ArgumentListBuilder(SPOON_CLIENT, "config");

            if (reset.or(Boolean.FALSE)) {
                buildArgs.add("--reset");
            }

            if (hub.isPresent()) {
                buildArgs.add("--hub=" + hub.get());
            }

            return new ConfigCommand(buildArgs);
        }
    }
}
<commit_msg>fix config command parsing regex<commit_after>package org.jenkinsci.plugins.spoontrigger.commands.turbo;

import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
import hudson.util.ArgumentListBuilder;
import org.jenkinsci.plugins.spoontrigger.commands.CommandDriver;
import org.jenkinsci.plugins.spoontrigger.commands.FilterOutputCommand;

import java.util.Collection;
import java.util.regex.Pattern;

public class ConfigCommand extends FilterOutputCommand {

    private static final Pattern HUB_URL_PATTERN = Pattern.compile("^Domain URL:\\s+(?<hubUrl>\\S+)$"); // todo: terrible. do not parse cli output looking for this information.


    private Optional<String> hub = Optional.absent();

    public Optional<String> getHub() {
        return hub;
    }

    ConfigCommand(ArgumentListBuilder argumentList) {
        super(argumentList);
    }

    @Override
    public void run(CommandDriver client) throws IllegalStateException {
        super.run(client);

        Collection<String> patterns = findInOutput(HUB_URL_PATTERN);
        if (patterns.size() > 0) {
            String hubUrl = Iterables.getLast(patterns);
            hub = Optional.of(hubUrl);
        }
    }

    public static CommandBuilder builder() {
        return new CommandBuilder();
    }

    public static class CommandBuilder {
        private Optional<Boolean> reset = Optional.absent();
        private Optional<String> hub = Optional.absent();

        public CommandBuilder reset(boolean value) {
            this.reset = Optional.of(value);
            return this;
        }

        public CommandBuilder hub(String hubUrl) {
            this.hub = Optional.of(hubUrl);
            return this;
        }

        public ConfigCommand build() {
            ArgumentListBuilder buildArgs = new ArgumentListBuilder(SPOON_CLIENT, "config");

            if (reset.or(Boolean.FALSE)) {
                buildArgs.add("--reset");
            }

            if (hub.isPresent()) {
                buildArgs.add("--hub=" + hub.get());
            }

            return new ConfigCommand(buildArgs);
        }
    }
}

{'fraction_non_alphanumeric': 0.10345655304848776, 'fraction_numerical': 0.00048007681228996637, 'mean_word_length': 2.5891472868217056, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5939822', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1106, 'n_words': 239}