Skip to content

sadasidha/JavaOptionParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Command Option Parser for Java

All the functions are written in a way where it either successfully executes or just throw exception. These includes validation. If invalid parameter or options are available function will throw exception.

Usage Example:

import java.util.ArrayList;

import com.simple.mind.optionreader.OptionParser;
import com.simple.mind.optionreader.annotations.Options;

public class Example {
	public static class Arguments {
		// this is not an optional parameter; if empty, error will be thrown

		ArrayList<String> fileNames;

		@Options(defaultValues = "false")
		boolean debug;
	}

	public static void main(String[] args) throws Exception {
		Arguments a = OptionsParser.parse(args, Arguments.class);
		System.out.println("Print all files");
		for (String fName : a.fileNames) {
			System.out.println("> " + fName);
		}
		System.out.println("Debug Value: " + a.debug);
	}
}

Execution

 java -classpath "$(pwd)/target/*" com.simple.mind.optionreader.example.Example --fileNames  name.json --fileNames phone.json --fileNames "address.json" "email-address.json" --file_names "additional.json"

Result

Print all files
> name.json
> phone.json
> address.json
> email-address.json
> additional.json
Debug Value: false

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages