<commit_before>package japicmp.cli;

import japicmp.config.Options;
import japicmp.exception.JApiCmpException;
import japicmp.util.Optional;
import japicmp.util.StringArrayEnumeration;

import static japicmp.model.AccessModifier.toModifier;
import static japicmp.util.FileHelper.createFileList;

public class CliParser {
	public static final String IGNORE_MISSING_CLASSES = "--ignore-missing-classes";
	public static final String IGNORE_MISSING_CLASSES_BY_REGEX = "--ignore-missing-classes-by-regex";
	public static final String OLD_CLASSPATH = "--old-classpath";
	public static final String NEW_CLASSPATH = "--new-classpath";

	public Options parse(String[] args) throws IllegalArgumentException {
		Options options = Options.newDefault();
		boolean includeExclusively = false;
		boolean excludeExclusively = false;
		StringArrayEnumeration sae = new StringArrayEnumeration(args);
		while (sae.hasMoreElements()) {
			String arg = sae.nextElement();
			if ("--include-exclusively".equals(arg)) {
				includeExclusively = true;
			} else if ("--exclude-exclusively".equals(arg)) {
				excludeExclusively = true;
			} else if ("-h".equals(arg) || "--help".equals(arg)) {
				options.setHelpRequested(true);
			}
		}
		if (options.isHelpRequested()) {
			return options;
		}
		sae = new StringArrayEnumeration(args);
		while (sae.hasMoreElements()) {
			String arg = sae.nextElement();
			if ("-n".equals(arg) || "--new".equals(arg)) {
				String newArchive = getOptionWithArgument("-n, --new", sae);
				options.getNewArchives().addAll(createFileList(checkNonNull(newArchive, "Required option -n is missing.")));
			} else if ("-o".equals(arg) || "--old".equals(arg)) {
				String oldArchive = getOptionWithArgument("-o, --old", sae);
				options.getOldArchives().addAll(createFileList(checkNonNull(oldArchive, "Required option -o is missing.")));
			} else if ("-m".equals(arg) || "--only-modified".equals(arg)) {
				options.setOutputOnlyModifications(true);
			} else if ("-b".equals(arg) || "--only-incompatible".equals(arg)) {
				options.setOutputOnlyBinaryIncompatibleModifications(true);
			} else if ("-a".equals(arg)) {
				String accessModifier = getOptionWithArgument("-a", sae);
				options.setAccessModifier(toModifier(accessModifier));
			} else if ("-i".equals(arg) || "--include".equals(arg)) {
				String includes = getOptionWithArgument("-i, --include", sae);
				options.addIncludeFromArgument(Optional.fromNullable(includes), includeExclusively);
			} else if ("-e".equals(arg) || "--exclude".equals(arg)) {
				String excludes = getOptionWithArgument("-e, --exclude", sae);
				options.addExcludeFromArgument(Optional.fromNullable(excludes), excludeExclusively);
			} else if ("-x".equals(arg) || "--xml-file".equals(arg)) {
				String pathToXmlOutputFile = getOptionWithArgument("-x, --xml-file", sae);
				options.setXmlOutputFile(Optional.fromNullable(pathToXmlOutputFile));
			} else if ("--html-file".equals(arg)) {
				String pathToHtmlOutputFile = getOptionWithArgument("--html-file", sae);
				options.setHtmlOutputFile(Optional.fromNullable(pathToHtmlOutputFile));
			} else if ("-s".equals(arg) || "--semantic-versioning".equals(arg)) {<commit_msg>Fixed ommision of exclusive filters in second while cycle<commit_after>package japicmp.cli;

import japicmp.config.Options;
import japicmp.exception.JApiCmpException;
import japicmp.util.Optional;
import japicmp.util.StringArrayEnumeration;

import static japicmp.model.AccessModifier.toModifier;
import static japicmp.util.FileHelper.createFileList;

public class CliParser {
	public static final String IGNORE_MISSING_CLASSES = "--ignore-missing-classes";
	public static final String IGNORE_MISSING_CLASSES_BY_REGEX = "--ignore-missing-classes-by-regex";
	public static final String OLD_CLASSPATH = "--old-classpath";
	public static final String NEW_CLASSPATH = "--new-classpath";

	public Options parse(String[] args) throws IllegalArgumentException {
		Options options = Options.newDefault();
		boolean includeExclusively = false;
		boolean excludeExclusively = false;
		StringArrayEnumeration sae = new StringArrayEnumeration(args);
		while (sae.hasMoreElements()) {
			String arg = sae.nextElement();
			if ("--include-exclusively".equals(arg)) {
				includeExclusively = true;
			} else if ("--exclude-exclusively".equals(arg)) {
				excludeExclusively = true;
			} else if ("-h".equals(arg) || "--help".equals(arg)) {
				options.setHelpRequested(true);
			}
		}
		if (options.isHelpRequested()) {
			return options;
		}
		sae = new StringArrayEnumeration(args);
		while (sae.hasMoreElements()) {
			String arg = sae.nextElement();
			if ("--include-exclusively".equals(arg) || "--exclude-exclusively".equals(arg)){
                // Do nothing
			} else if ("-n".equals(arg) || "--new".equals(arg)) {
				String newArchive = getOptionWithArgument("-n, --new", sae);
				options.getNewArchives().addAll(createFileList(checkNonNull(newArchive, "Required option -n is missing.")));
			} else if ("-o".equals(arg) || "--old".equals(arg)) {
				String oldArchive = getOptionWithArgument("-o, --old", sae);
				options.getOldArchives().addAll(createFileList(checkNonNull(oldArchive, "Required option -o is missing.")));
			} else if ("-m".equals(arg) || "--only-modified".equals(arg)) {
				options.setOutputOnlyModifications(true);
			} else if ("-b".equals(arg) || "--only-incompatible".equals(arg)) {
				options.setOutputOnlyBinaryIncompatibleModifications(true);
			} else if ("-a".equals(arg)) {
				String accessModifier = getOptionWithArgument("-a", sae);
				options.setAccessModifier(toModifier(accessModifier));
			} else if ("-i".equals(arg) || "--include".equals(arg)) {
				String includes = getOptionWithArgument("-i, --include", sae);
				options.addIncludeFromArgument(Optional.fromNullable(includes), includeExclusively);
			} else if ("-e".equals(arg) || "--exclude".equals(arg)) {
				String excludes = getOptionWithArgument("-e, --exclude", sae);
				options.addExcludeFromArgument(Optional.fromNullable(excludes), excludeExclusively);
			} else if ("-x".equals(arg) || "--xml-file".equals(arg)) {
				String pathToXmlOutputFile = getOptionWithArgument("-x, --xml-file", sae);
				options.setXmlOutputFile(Optional.fromNullable(pathToXmlOutputFile));
			} else if ("--html-file".equals(arg)) {
				String pathToHtmlOutputFile = getOptionWithArgument("--html-file", sae);
				options.setHtmlOutputFile(Optional.fromNullable(pathToHtmlOutputFile));
			} else if ("-s".equals(arg) || "--semantic-versioning".equals(arg)) {
{'fraction_non_alphanumeric': 0.1536103020082784, 'fraction_numerical': 0.0, 'mean_word_length': 4.788819875776397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4547932', 'n_tokens_mistral': 2231, 'n_tokens_neox': 1998, 'n_words': 382}