<commit_before>package bpelviz;

import org.apache.commons.cli.*;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

/**
 * The parameters for the cli.
 */
public class Cli {

    private Options options;
    private CommandLine cmd;

    public Cli(String[] args) {
        options = new Options();
        options.addOption("o", "open-in-browser", false, "opens html file in default browser");

        CommandLineParser parser = new BasicParser();

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e) {
            printUsageAndExit("Internal error (" + e.getMessage() + ")");
        }

        validate();
    }

    public void validate() {
        if (cmd.getArgList().isEmpty()) {
            printUsageAndExit("No bpel file given as input");
        }

        if (!Files.isRegularFile(getBpelFile())) {
            printUsageAndExit("Given bpel file " + getBpelFile() + " is no regular file");
        }

        if (!Files.exists(getBpelFile())) {
            printUsageAndExit("Given bpel file " + getBpelFile() + " does not exists");
        }

        if (!getBpelFile().toString().endsWith(".bpel")) {
            printUsageAndExit("Given file " + getBpelFile() + " is no bpel file");
        }

        if (!Files.isRegularFile(getHtmlFile())) {
            printUsageAndExit("Given bpel file " + getBpelFile() + " is no regular file");
        }

        if (!getHtmlFile().toString().endsWith(".html")) {
            printUsageAndExit("Given file " + getHtmlFile() + " is no html file");
        }
    }

    public Path getHtmlFile() {
        if (cmd.getArgs().length == 2) {
            return Paths.get(cmd.getArgs()[1]);
        } else {
            Path bpelFile = getBpelFile().toAbsolutePath();
            String bpelFileName = bpelFile.getFileName().toString();
            String htmlFileName = bpelFileName.replace(".bpel", ".html");
            return bpelFile.getParent().resolve(htmlFileName);
        }
    }

    public boolean openHtmlInBrowser() {
        return cmd.hasOption("o");
    }

    private void printUsageAndExit(String message) {
        System.err.println("Error: " + message);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("BPELviz [options] BPEL_FILE [HTML_FILE]", options);
        System.exit(-1);
    }

    public Path getBpelFile() {
        Object first = cmd.getArgList().get(0);
        return Paths.get(first.toString());
    }
}
<commit_msg>Fixes bug that made the CLI tool useless<commit_after>package bpelviz;

import org.apache.commons.cli.*;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

/**
 * The parameters for the cli.
 */
public class Cli {

    private Options options;
    private CommandLine cmd;

    public Cli(String[] args) {
        options = new Options();
        options.addOption("o", "open-in-browser", false, "opens html file in default browser");

        CommandLineParser parser = new BasicParser();

        try {
            cmd = parser.parse(options, args);
        } catch (ParseException e) {
            printUsageAndExit("Internal error (" + e.getMessage() + ")");
        }

        validate();
    }

    public void validate() {
        if (cmd.getArgList().isEmpty()) {
            printUsageAndExit("No bpel file given as input");
        }

        if (!Files.isRegularFile(getBpelFile())) {
            printUsageAndExit("Given bpel file " + getBpelFile() + " is no regular file");
        }

        if (!Files.exists(getBpelFile())) {
            printUsageAndExit("Given bpel file " + getBpelFile() + " does not exists");
        }

        if (!getBpelFile().toString().endsWith(".bpel")) {
            printUsageAndExit("Given file " + getBpelFile() + " is no bpel file");
        }

        if (!getHtmlFile().toString().endsWith(".html")) {
            printUsageAndExit("Given file " + getHtmlFile() + " is no html file");
        }
    }

    public Path getHtmlFile() {
        if (cmd.getArgs().length == 2) {
            return Paths.get(cmd.getArgs()[1]);
        } else {
            Path bpelFile = getBpelFile().toAbsolutePath();
            String bpelFileName = bpelFile.getFileName().toString();
            String htmlFileName = bpelFileName.replace(".bpel", ".html");
            return bpelFile.getParent().resolve(htmlFileName);
        }
    }

    public boolean openHtmlInBrowser() {
        return cmd.hasOption("o");
    }

    private void printUsageAndExit(String message) {
        System.err.println("Error: " + message);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("BPELviz [options] BPEL_FILE [HTML_FILE]", options);
        System.exit(-1);
    }

    public Path getBpelFile() {
        Object first = cmd.getArgList().get(0);
        return Paths.get(first.toString());
    }
}

{'fraction_non_alphanumeric': 0.13724304715840388, 'fraction_numerical': 0.0016122531237404273, 'mean_word_length': 2.3670284938941655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5272602', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1399, 'n_words': 325}