public abstract class CommandLine extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CommandLine.HelpRequestedException |
| Constructor and Description |
|---|
CommandLine() |
| Modifier and Type | Method and Description |
|---|---|
void |
addOption(String option,
String argumentDesc,
String description)
Add an option requiring an argument.
|
void |
addSwitch(String option,
String description)
Add a command line switch.
|
void |
addSwitchWithOptionalExtraPart(String option,
String optionExtraPartSynopsis,
String description)
Add a command line switch that allows optional extra information to be
specified as part of it.
|
String[] |
expandOptionFiles(String[] argv,
boolean ignoreComments,
boolean ignoreBlankLines)
Expand option files in given command line.
|
static ArrayList<String> |
getAnalysisOptionProperties(boolean ignoreComments,
boolean ignoreBlankLines) |
protected abstract void |
handleOption(String option,
String optionExtraPart)
Callback method for handling an option.
|
protected abstract void |
handleOptionWithArgument(String option,
String argument)
Callback method for handling an option with an argument.
|
void |
makeOptionUnlisted(String option)
Don't list this option when printing Usage information
|
int |
parse(String[] argv)
Parse a command line.
|
int |
parse(String[] argv,
int minArgs,
int maxArgs,
String usage)
Parse switches/options, showing usage information if they can't be
parsed, or if we have the wrong number of remaining arguments after
parsing.
|
void |
printUsage(OutputStream os)
Print command line usage information to given stream.
|
void |
startOptionGroup(String description)
Start a new group of related command-line options.
|
public void startOptionGroup(String description)
description - description of the grouppublic void addSwitch(String option, String description)
option - the option, must start with "-"description - single line description of the optionpublic void addSwitchWithOptionalExtraPart(String option, String optionExtraPartSynopsis, String description)
option - the option, must start with "-"optionExtraPartSynopsis - synopsis of the optional extra informationdescription - single-line description of the optionpublic void addOption(String option, String argumentDesc, String description)
option - the option, must start with "-"argumentDesc - brief (one or two word) description of the argumentdescription - single line description of the optionpublic void makeOptionUnlisted(String option)
option - public String[] expandOptionFiles(String[] argv, boolean ignoreComments, boolean ignoreBlankLines) throws IOException, CommandLine.HelpRequestedException
argv - the original command lineignoreComments - ignore comments (lines starting with "#")ignoreBlankLines - ignore blank linesIOExceptionCommandLine.HelpRequestedExceptionpublic static ArrayList<String> getAnalysisOptionProperties(boolean ignoreComments, boolean ignoreBlankLines)
public int parse(String[] argv, int minArgs, int maxArgs, String usage)
argv - command line argumentsminArgs - allowed minimum number of arguments remaining after
switches/options are parsedmaxArgs - allowed maximum number of arguments remaining after
switches/options are parsedusage - usage synopsispublic int parse(String[] argv) throws IOException, CommandLine.HelpRequestedException
argv - the argumentsCommandLine.HelpRequestedExceptionIOExceptionprotected abstract void handleOption(String option, String optionExtraPart) throws IOException
option - the optionoptionExtraPart - the "extra" part of the option (everything after the colon:
e.g., "withMessages" in "-xml:withMessages"); the empty string
if there was no extra partIOExceptionprotected abstract void handleOptionWithArgument(String option, String argument) throws IOException
option - the optionargument - the argumentIOExceptionpublic void printUsage(OutputStream os)
os - the output streamCopyright © 2003–2015. All rights reserved.