Package dk.eSoftware.commandLineParser
Class CommandLineParser<T extends Configuration>
- java.lang.Object
-
- dk.eSoftware.commandLineParser.CommandLineParser<T>
-
- Direct Known Subclasses:
MultiParser,SingletonCommandLineParser
public abstract class CommandLineParser<T extends Configuration> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommandLineParser.Commandstatic interfaceCommandLineParser.ConfigBuilder<T extends Configuration>
-
Constructor Summary
Constructors Constructor Description CommandLineParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract CommandLineParser.ConfigBuilder<? extends T>getConfigBuilder(java.lang.String firstParam)Method that must be implemented retrieving the correct configBuilder given first argumentabstract java.lang.Stringhelp()Tparse(java.lang.String[] input)Utility for parsing commandline parameters into configuration objects
-
-
-
Method Detail
-
parse
public T parse(java.lang.String[] input) throws NoSuchBuilderException, WrongFormatException, UnknownCommandException
Utility for parsing commandline parameters into configuration objectsAll commands parsable by the commandLineParser is of the form:
--mode --param1 -arg1 -arg2 --param2 --param3 -arg1mode is what determines theCommandLineParser.ConfigBuilderused
Note that the first argument that theCommandLineParser.ConfigBuilderreceives is always the mode argument. The mode is also able to receive get arguments, however they wont affect choice ofCommandLineParser.ConfigBuilder
Both commands and arguments are stripped of their "-" or "--" prefix- Parameters:
input- the string array to be parsed- Returns:
- null if input is null or empty - otherwise a
Configurationcreated by the assignedCommandLineParser.ConfigBuilder - Throws:
NoSuchBuilderExceptionWrongFormatExceptionUnknownCommandException
-
getConfigBuilder
protected abstract CommandLineParser.ConfigBuilder<? extends T> getConfigBuilder(java.lang.String firstParam) throws NoSuchBuilderException
Method that must be implemented retrieving the correct configBuilder given first argument- Parameters:
firstParam- first argument from commandline- Returns:
CommandLineParser.ConfigBuilderto be used in parsing- Throws:
NoSuchBuilderException- when noCommandLineParser.ConfigBuilderis found
-
help
public abstract java.lang.String help()
- Returns:
- terminal-formatted string describing configuration options
-
-