public class CommandLine
extends java.lang.Object
Some terminology used below:
Features to be added, roughly in order of importance:
getopt()
function.
Modifier and Type | Class and Description |
---|---|
class |
CommandLine.OptionStyle
This class is used to store the option style.
|
static class |
CommandLine.ParseException
An Exception thrown by the CommandLine class.
|
static class |
CommandLine.ParseResult
This class is used to store the result of a command line parse.
|
static class |
CommandLine.ResponseFileExpander
This class expands a response file.
|
static class |
CommandLine.ValidOptions
This class is used to store and check which options are valid.
|
Constructor and Description |
---|
CommandLine()
Create an empty CommandLine instance; no parsing is done.
|
CommandLine(java.lang.String[] args)
Create a CommandLine parser for the given command line;
no parsing is done.
|
CommandLine(java.lang.String[] args,
java.util.List<java.lang.String> flagOptions,
java.util.List<java.lang.String> flargOptions,
java.util.List<java.lang.String> argOptions)
Parse a command line using the given options.
|
CommandLine(java.lang.String[] args,
java.lang.String[] flagOptions,
java.lang.String[] flargOptions,
java.lang.String[] argOptions)
Parse a command line using the given options.
|
CommandLine(java.lang.String[] args,
java.lang.String flagOptions,
java.lang.String flargOptions)
Parse a command line using short options only.
|
CommandLine(java.lang.String[] args,
java.lang.String flagOptions,
java.lang.String flargOptions,
java.lang.String argOptions)
Parse a command line using the given short options.
|
CommandLine(java.lang.String[] args,
java.lang.String shortFlagOptions,
java.lang.String shortFlargOptions,
java.lang.String[] longFlagOptions,
java.lang.String[] longFlargOptions)
Parse a command line using the given short and options.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getCommandLine()
Get (a clone of) the command line.
|
CommandLine.OptionStyle |
optionStyle()
Get the option style.
|
void |
parse()
Parse the command line.
|
CommandLine.ParseResult |
parseResult()
Get the parse result.
|
void |
setCommandLine(java.lang.String[] args)
Set the command line.
|
CommandLine.ValidOptions |
validOptions()
Get the valid options.
|
public CommandLine()
public CommandLine(java.lang.String[] args)
args
- a command linepublic CommandLine(java.lang.String[] args, java.lang.String[] flagOptions, java.lang.String[] flargOptions, java.lang.String[] argOptions) throws CommandLine.ParseException
args
- the command line to be parsedflagOptions
- the flag options allowedflargOptions
- the flarg options allowedargOptions
- the flarg options allowedCommandLine.ParseException
- the format of
the command line is not validpublic CommandLine(java.lang.String[] args, java.lang.String flagOptions, java.lang.String flargOptions) throws CommandLine.ParseException
Provided for compatibility with PJ's Commandline class only.
args
- the command line to be parsedflagOptions
- the short flag options allowedflargOptions
- the short flarg options allowedCommandLine.ParseException
- the format of
the command line is not validpublic CommandLine(java.lang.String[] args, java.lang.String shortFlagOptions, java.lang.String shortFlargOptions, java.lang.String[] longFlagOptions, java.lang.String[] longFlargOptions) throws CommandLine.ParseException
Provided for compatibility with PJ's Commandline class only.
args
- the command line to be parsedshortFlagOptions
- the short flag options allowedshortFlargOptions
- the short flarg options allowedlongFlagOptions
- the long flag options allowedlongFlargOptions
- the long flarg options allowedCommandLine.ParseException
- the format of
the command line is not validpublic CommandLine(java.lang.String[] args, java.lang.String flagOptions, java.lang.String flargOptions, java.lang.String argOptions) throws CommandLine.ParseException
args
- the command line to be parsedflagOptions
- the flag options allowedflargOptions
- the flarg options allowedargOptions
- the flarg options allowedCommandLine.ParseException
- the format of
the command line is not validpublic CommandLine(java.lang.String[] args, java.util.List<java.lang.String> flagOptions, java.util.List<java.lang.String> flargOptions, java.util.List<java.lang.String> argOptions) throws CommandLine.ParseException
args
- the command line to be parsedflagOptions
- the flag options allowedflargOptions
- the flarg options allowedargOptions
- the flarg options allowedCommandLine.ParseException
- the format of
the command line is not validpublic CommandLine.OptionStyle optionStyle()
public CommandLine.ValidOptions validOptions()
public CommandLine.ParseResult parseResult()
public final void setCommandLine(java.lang.String[] args)
args
- the new command linepublic java.lang.String[] getCommandLine()
public final void parse() throws CommandLine.ParseException
CommandLine.ParseException
- the command line
is invalid