All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clumd.projects.java_common_utils.Main Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
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");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy