com.clumd.projects.java_common_utils.Main Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common-utils Show documentation
Show all versions of java-common-utils Show documentation
A collection of common utilities I find myself writing for most Java projects
package com.clumd.projects.java_common_utils;
import com.clumd.projects.java_common_utils.arg_parser.Argument;
import com.clumd.projects.java_common_utils.arg_parser.CLIArgParser;
import com.clumd.projects.java_common_utils.arg_parser.JavaArgParser;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public class Main {
public static void main(String[] args) throws ParseException {
CLIArgParser parser = new JavaArgParser();
List> actual = new ArrayList<>(parser.parseFromCLI(List.of(Argument.builder()
.uniqueId(1)
.description("A number between 10 and 30")
.shortOptions(Set.of('n'))
.longOptions(Set.of("number", "input"))
.isMandatory(true)
.hasValue(true)
.valueIsOptional(false)
.conversionFunction(Integer::parseInt)
.validationFunction(i -> i > 10 && i < 30)
.defaultValue(18)
.build()),
args
));
System.out.printf("\n\n");
System.out.printf(actual.get(0).getArgumentResult().toString());
System.out.printf("\n\n");
}
}