Package org.dellroad.jct.core.simple
Class SimpleCommandLineParser
java.lang.Object
org.dellroad.jct.core.simple.SimpleCommandLineParser
- All Implemented Interfaces:
CommandLineParser
A simple command line parser:
- Command name and parameters are separated by whitespace
- Java-style doubly-quoted string literals are supported, and may span multiple lines
- Backslash escapes are supported for (in particular) double quote and backslash characters
- Backslash escapes are supported for end of line continuations to the next line
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.dellroad.jct.core.simple.CommandLineParser
CommandLineParser.SyntaxException
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseCommandLine
(String line) Parse the given command line into a command name and parameters.
-
Constructor Details
-
SimpleCommandLineParser
public SimpleCommandLineParser()
-
-
Method Details
-
parseCommandLine
Description copied from interface:CommandLineParser
Parse the given command line into a command name and parameters.If the line contains a syntax error, then a
CommandLineParser.SyntaxException
should be thrown.If the line does not contain even a command name, for example is pure whitespace, then an empty list should be returned.
If the line contains ends with an incomplete parse (e.g., with a backslash continuation character), then null should be returned. In this case the caller should read another line of input, append it to the original (after adding a line terminator), and then invoke this method again.
- Specified by:
parseCommandLine
in interfaceCommandLineParser
- Parameters:
line
- command line- Returns:
- parsed command line
- Throws:
CommandLineParser.SyntaxException
- ifline
contains a syntax error
-