Package io.permazen.cli
Class ParamParser
java.lang.Object
io.permazen.cli.ParamParser
Parses command line parameters, including optional flags, based on a specification string.
The specification string contains whitespace-separated parameter specifications; see ParamParser.Param
for syntax.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Represents one parsed parameter specification. -
Constructor Summary
-
Method Summary
-
Constructor Details
-
ParamParser
-
-
Method Details
-
getUsage
Build a usage summary string.- Parameters:
commandName
- command name- Returns:
- usage string
-
getOptionFlags
Get option flags.- Returns:
- optional parameters
-
getParameters
Get regular parameters, in expected order.- Returns:
- mandatory parameters
-
getParser
Convert parameter spec type name into aParser
.The implementation in
ParamParser
supports all of the pre-defined types ofEncodingRegistry
(identified by their encoding ID's or aliases), plusword
to parse aString
containing one or more non-whitespace characters. Subclasses should override as required to add additional supported types.- Parameters:
typeName
- name of type- Returns:
- parser for parameters of the specified type
- Throws:
IllegalArgumentException
- iftypeName
is unknown
-
parse
Parse command line parameters.- Parameters:
session
- associated sessionparams
- command parameters- Throws:
ParseException
- if parse fails
-