Class CmdParser
java.lang.Object
ch.turic.cli.CmdParser
Command-line parser class designed to handle structured input in the form of keys and standalone parameters.
The parsing supports flexible key-value pairs and standalone arguments while ensuring strict validation
of key uniqueness and potential unambiguous prefix matching for allowed parameters.
-
Constructor Details
-
CmdParser
public CmdParser()
-
-
Method Details
-
parse
Parse a string and build up the parsed structures.A line can have the form
key1=value1 key2=value2 .... parameter ... key3=value3 ... parameterThe keys have to be unique, so no one key can be used twice. The parameters that stand alone on the line without an associated key can be mixed between, before and after the keys.
The keys, in case they are defined in the argument
parametersare case-insensitive.- Parameters:
parts- the line that contains the keys and also the argumentsparameters- a set of parameter names that are allowed on the line. In case this parameter is null, any parameter is allowed. If this set is empty, then no parameter is allowed. If the set contains the parameter names, then the line may use any non-ambiguous prefix of any parameter, and the parsed structure will contain the full parameter name even if the user typed a short prefix.- Returns:
- the parsed structure object that can later be queried
- Throws:
IllegalArgumentException- if the line is not properly formatted
-
get
-
get
-