<commit_before>package pt.brunoais.cli_args_parser;

import pt.brunoais.cli_args_parser.callbacks.DoubleValCallback;
import pt.brunoais.cli_args_parser.callbacks.NoValCallback;
import pt.brunoais.cli_args_parser.callbacks.QuadrupleValCallback;
import pt.brunoais.cli_args_parser.callbacks.SingleValCallback;
import pt.brunoais.cli_args_parser.callbacks.TripleValCallback;
import pt.brunoais.cli_args_parser.callbacks.ValCallback;

public class Argument {

	String name;
	private ParseArgs registerTo;

	private String key;
	private int multiplicity;
	private boolean nameIsPrefix;
	private boolean keyEqValue;
	private ValCallback callback;

	Argument(String name, ParseArgs registerTo) {
		this.name = name;
		this.registerTo = registerTo;
		this.multiplicity = 0;
	}
	
	public Argument key(String key) {
		this.key = key;
		return this;
	}
	
	public Argument equalValue(){
		return keyEqualValue();
	}
	
	public Argument keyEqualValue(){
		keyEqValue = true;
		return this;
	}

	public Argument keySpaceValue(){
		return spaceValue();
	}
	
	public Argument spaceValue(){
		multiplicity = 1;
		return this;
	}
	
	public Argument spaceValued(int times){
		multiplicity = times;
		return this;
	}
	
	public void call(NoValCallback callback){
		call((ValCallback) callback);
	}
	public void call(SingleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(DoubleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(TripleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(QuadrupleValCallback callback){
		call((ValCallback) callback);
	}
	
	private void call(ValCallback callback){
		this.callback = callback;
		if(nameIsPrefix){
			registerTo.appendPrefixed(this);
		} else if(name == null || name.isEmpty()){
			registerTo.setDefault(this);
		} else {
			registerTo.appendNormal(this);
		}
	}
	
	void found(String value){
		callback.c("", "", value);
	}
	
	int parse(String[] args, int startNum){
		int workingNum = startNum;
		String workingArg = args[workingNum];
		String key = workingArg;
		String keyValueValue = "";
		
		if(nameIsPrefix){
			key = workingArg.substring(name.length());
		}
		if(keyEqValue){
			String[] key_value = key.split("=", 2);
			key = key_value[0];
			keyValueValue = key_value[1];
		}

		workingNum += 1;
		
		if(multiplicity == 0){
			callback.c(name, key, keyValueValue);
		} else {
			int getUntil = startNum + multiplicity + 1;
			
			for (; workingNum < getUntil; workingNum++) {
				if(keyEqValue){
					callback.c(name, key, keyValueValue, args[workingNum]);
				} else {
					callback.c(name, key, args[workingNum]);
				}
			}
		}
		
		return workingNum;
		
	}
	
}<commit_msg>Cleanup<commit_after>package pt.brunoais.cli_args_parser;

import pt.brunoais.cli_args_parser.callbacks.DoubleValCallback;
import pt.brunoais.cli_args_parser.callbacks.NoValCallback;
import pt.brunoais.cli_args_parser.callbacks.QuadrupleValCallback;
import pt.brunoais.cli_args_parser.callbacks.SingleValCallback;
import pt.brunoais.cli_args_parser.callbacks.TripleValCallback;
import pt.brunoais.cli_args_parser.callbacks.ValCallback;

public class Argument {

	String name;
	private ParseArgs registerTo;

	private String key;
	private int multiplicity;
	private boolean nameIsPrefix;
	private boolean keyEqValue;
	private ValCallback callback;

	Argument(String name, ParseArgs registerTo) {
		this.name = name;
		this.registerTo = registerTo;
		this.multiplicity = 0;
	}
	
	public Argument key(String key) {
		this.key = key;
		return this;
	}
	
	public Argument equalValue(){
		return keyEqualValue();
	}
	
	public Argument keyEqualValue(){
		keyEqValue = true;
		return this;
	}

	public Argument keySpaceValue(){
		return spaceValue();
	}
	
	public Argument spaceValue(){
		multiplicity = 1;
		return this;
	}
	
	public Argument spaceValued(int times){
		multiplicity = times;
		return this;
	}
	
	
	void found(String value){
		callback.c("", "", value);
	}
	
	int parse(String[] args, int startNum){
		int workingNum = startNum;
		String workingArg = args[workingNum];
		String key = workingArg;
		String keyValueValue = "";
		
		if(nameIsPrefix){
			key = workingArg.substring(name.length());
		}
		if(keyEqValue){
			String[] key_value = key.split("=", 2);
			key = key_value[0];
			keyValueValue = key_value[1];
		}

		workingNum += 1;
		
		if(multiplicity == 0){
			callback.c(name, key, keyValueValue);
		} else {
			int getUntil = startNum + multiplicity + 1;
			
			for (; workingNum < getUntil; workingNum++) {
				if(keyEqValue){
					callback.c(name, key, keyValueValue, args[workingNum]);
				} else {
					callback.c(name, key, args[workingNum]);
				}
			}
		}
		
		return workingNum;
		
	}
	
	private void call(ValCallback callback){
		this.callback = callback;
		if(nameIsPrefix){
			registerTo.appendPrefixed(this);
		} else if(name == null || name.isEmpty()){
			registerTo.setDefault(this);
		} else {
			registerTo.appendNormal(this);
		}
	}
	
	public void call(NoValCallback callback){
		call((ValCallback) callback);
	}
	public void call(SingleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(DoubleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(TripleValCallback callback){
		call((ValCallback) callback);
	}
	public void call(QuadrupleValCallback callback){
		call((ValCallback) callback);
	}
}
{'fraction_non_alphanumeric': 0.11363636363636363, 'fraction_numerical': 0.0029806259314456036, 'mean_word_length': 4.33167825223436, 'pattern_counts': {'":': 0, '<': 5, '<?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': '673765', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1710, 'n_words': 386}