<commit_before>package com.hazelcast.stabilizer.provisioner;

import com.hazelcast.logging.ILogger;
import com.hazelcast.stabilizer.Utils;
import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;

import java.io.File;

import static com.hazelcast.stabilizer.Utils.getStablizerHome;
import static java.lang.String.format;

public class ProvisionerCli {
    private final static File STABILIZER_HOME = getStablizerHome();
    private final static ILogger log = com.hazelcast.logging.Logger.getLogger(ProvisionerCli.class);

    public final OptionParser parser = new OptionParser();

    public final OptionSpec restartSpec = parser.accepts("restart",
            "Restarts all agents");

    public final OptionSpec downloadSpec = parser.accepts("download",
            "Download all the files from the workers directory. " +
                    "To delete all worker directories, add the --clean option"
    );

    public final OptionSpec cleanSpec = parser.accepts("clean",
            "Cleans the workers directories. ");

    public final OptionSpec<Integer> scaleSpec = parser.accepts("scale",
            "Number of machines to scale to")
            .withRequiredArg().ofType(Integer.class);

    public final OptionSpec terminateSpec = parser.accepts("terminateWorker",
            "Terminate all members in the provisioner");

    public final OptionSpec killSpec = parser.accepts("kill",
            "Kill all agents");

    public final OptionSpec helpSpec = parser.accepts("help", "Show help").forHelp();

    private final OptionSpec<String> propertiesFileSpec = parser.accepts("propertiesFile",
            "The file containing the stabilizer properties. If no file is explicitly configured, first the " +
                    "working directory is checked for a file 'stabilizer.properties'. If that doesn't exist, then" +
                    "the STABILIZER_HOME/conf/stabilizer.properties is loaded."
    )
            .withRequiredArg().ofType(String.class);

    private final Provisioner provisioner;

    public ProvisionerCli(Provisioner provisioner) {
        this.provisioner = provisioner;
    }

    public void run(String[] args) throws Exception {
        OptionSet options;
        try {
            options = parser.parse(args);
        } catch (OptionException e) {
            Utils.exitWithError(log, e.getMessage() + ". Use --help to get overview of the help options.");
            return;//
        }

        if (options.has(helpSpec)) {
            parser.printHelpOn(System.out);
            System.exit(0);
        }
        File propertiesFile = getPropertiesFile(options);
        log.info(format("stabilizer.properties: %s", provisioner.props.getFile().getAbsolutePath()));
        provisioner.props.load(propertiesFile);

        provisioner.init();
<commit_msg>Fixed npe in provisioner<commit_after>package com.hazelcast.stabilizer.provisioner;

import com.hazelcast.logging.ILogger;
import com.hazelcast.stabilizer.Utils;
import joptsimple.OptionException;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;

import java.io.File;

import static com.hazelcast.stabilizer.Utils.getStablizerHome;
import static java.lang.String.format;

public class ProvisionerCli {
    private final static File STABILIZER_HOME = getStablizerHome();
    private final static ILogger log = com.hazelcast.logging.Logger.getLogger(ProvisionerCli.class);

    public final OptionParser parser = new OptionParser();

    public final OptionSpec restartSpec = parser.accepts("restart",
            "Restarts all agents");

    public final OptionSpec downloadSpec = parser.accepts("download",
            "Download all the files from the workers directory. " +
                    "To delete all worker directories, add the --clean option"
    );

    public final OptionSpec cleanSpec = parser.accepts("clean",
            "Cleans the workers directories. ");

    public final OptionSpec<Integer> scaleSpec = parser.accepts("scale",
            "Number of machines to scale to")
            .withRequiredArg().ofType(Integer.class);

    public final OptionSpec terminateSpec = parser.accepts("terminateWorker",
            "Terminate all members in the provisioner");

    public final OptionSpec killSpec = parser.accepts("kill",
            "Kill all agents");

    public final OptionSpec helpSpec = parser.accepts("help", "Show help").forHelp();

    private final OptionSpec<String> propertiesFileSpec = parser.accepts("propertiesFile",
            "The file containing the stabilizer properties. If no file is explicitly configured, first the " +
                    "working directory is checked for a file 'stabilizer.properties'. If that doesn't exist, then" +
                    "the STABILIZER_HOME/conf/stabilizer.properties is loaded."
    )
            .withRequiredArg().ofType(String.class);

    private final Provisioner provisioner;

    public ProvisionerCli(Provisioner provisioner) {
        this.provisioner = provisioner;
    }

    public void run(String[] args) throws Exception {
        OptionSet options;
        try {
            options = parser.parse(args);
        } catch (OptionException e) {
            Utils.exitWithError(log, e.getMessage() + ". Use --help to get overview of the help options.");
            return;//
        }

        if (options.has(helpSpec)) {
            parser.printHelpOn(System.out);
            System.exit(0);
        }
        File propertiesFile = getPropertiesFile(options);
        provisioner.props.load(propertiesFile);
        log.info(format("stabilizer.properties: %s", provisioner.props.getFile().getAbsolutePath()));

        provisioner.init();

{'fraction_non_alphanumeric': 0.09411356138218441, 'fraction_numerical': 0.0003472825143254037, 'mean_word_length': 3.01673640167364, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5939658', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1501, 'n_words': 411}