Class CommandLine
java.lang.Object
edu.umd.cs.findbugs.config.CommandLine
- Direct Known Subclasses:
Churn.ChurnCommandLine, CountClassVersions.CountClassVersionsCommandLine, Filter.FilterCommandLine, FindBugsCommandLine, ListBugDatabaseInfo.ListBugDatabaseInfoCommandLine, MergeSummarizeAndView.MSVCommandLine, MineBugHistory.MineBugHistoryCommandLine, ObfuscateBugs.CommandLine, PrintingBugReporter.PrintingCommandLine, RebornIssues.CommandLine, RejarClassesForAnalysis.RejarClassesForAnalysisCommandLine, SetBugDatabaseInfo.SetInfoCommandLine, TestingGround.CommandLine, UnionResults.UnionResultsCommandLine, Update.UpdateCommandLine
Helper class for parsing command line arguments.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class(package private) static final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddCommandLineOptions(ArrayList<String> resultList, BufferedReader reader, boolean ignoreComments, boolean ignoreBlankLines) voidAdd an option requiring an argument.voidAdd a command line switch.voidaddSwitchWithOptionalExtraPart(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.getAnalysisOptionProperties(boolean ignoreComments, boolean ignoreBlankLines) protected abstract voidhandleOption(String option, String optionExtraPart) Callback method for handling an option.protected abstract voidhandleOptionWithArgument(String option, String argument) Callback method for handling an option with an argument.voidmakeOptionUnlisted(String option) Don't list this option when printing Usage informationintParse a command line.private intintParse switches/options, showing usage information if they can't be parsed, or if we have the wrong number of remaining arguments after parsing.private static voidprintField(PrintStream out, String s, int width) voidPrint command line usage information to given stream.(package private) static CommandLine.OptionsplitOption(String option) voidstartOptionGroup(String description) Start a new group of related command-line options.
-
Field Details
-
SPACES
- See Also:
-
optionList
-
unlistedOptions
-
optionGroups
-
requiresArgumentSet
-
optionDescriptionMap
-
optionExtraPartSynopsisMap
-
argumentDescriptionMap
-
maxWidth
int maxWidth
-
-
Constructor Details
-
CommandLine
protected CommandLine()
-
-
Method Details
-
startOptionGroup
Start a new group of related command-line options.- Parameters:
description- description of the group
-
addSwitch
-
addSwitchWithOptionalExtraPart
public 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.- Parameters:
option- the option, must start with "-"optionExtraPartSynopsis- synopsis of the optional extra informationdescription- single-line description of the option
-
addOption
-
makeOptionUnlisted
Don't list this option when printing Usage information- Parameters:
option-
-
expandOptionFiles
public String[] expandOptionFiles(String[] argv, boolean ignoreComments, boolean ignoreBlankLines) throws IOException, CommandLine.HelpRequestedException Expand option files in given command line. Any token beginning with "@" is assumed to be an option file. Option files contain one command line option per line.- Parameters:
argv- the original command lineignoreComments- ignore comments (lines starting with "#")ignoreBlankLines- ignore blank lines- Returns:
- the expanded command line
- Throws:
IOExceptionCommandLine.HelpRequestedException
-
getAnalysisOptionProperties
-
addCommandLineOptions
private static void addCommandLineOptions(ArrayList<String> resultList, BufferedReader reader, boolean ignoreComments, boolean ignoreBlankLines) throws IOException - Throws:
IOException
-
parse
Parse switches/options, showing usage information if they can't be parsed, or if we have the wrong number of remaining arguments after parsing. Calls parse(String[]).- Parameters:
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 synopsis- Returns:
- number of arguments parsed
-
parse
Parse a command line. Calls down to handleOption() and handleOptionWithArgument() methods. Stops parsing when it reaches the end of the command line, or when a command line argument not starting with "-" is seen.- Parameters:
argv- the arguments- Returns:
- the number of arguments parsed; if equal to argv.length, then the entire command line was parsed
- Throws:
CommandLine.HelpRequestedExceptionIOException
-
parse
private int parse(String[] argv, boolean dryRun) throws IOException, CommandLine.HelpRequestedException -
splitOption
-
handleOption
Callback method for handling an option.- Parameters:
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 part- Throws:
IOException
-
handleOptionWithArgument
Callback method for handling an option with an argument.- Parameters:
option- the optionargument- the argument- Throws:
IOException
-
printUsage
Print command line usage information to given stream.- Parameters:
os- the output stream
-
printField
-