Package org.eclipse.jgit.pgm.opt
Class CmdLineParser
- java.lang.Object
-
- org.kohsuke.args4j.CmdLineParser
-
- org.eclipse.jgit.pgm.opt.CmdLineParser
-
- Direct Known Subclasses:
Main.SubcommandLineParser
public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser
Extended command line parser which handles --foo=value arguments.The args4j package does not natively handle --foo=value and instead prefers to see --foo value on the command line. Many users are used to the GNU style --foo=value long option, so we convert from the GNU style format to the args4j style format prior to invoking args4j for parsing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
CmdLineParser.MyOptionDef
-
Field Summary
Fields Modifier and Type Field Description private TextBuiltin
cmd
private Repository
db
private boolean
seenHelp
private RevWalk
walk
-
Constructor Summary
Constructors Constructor Description CmdLineParser(java.lang.Object bean)
Creates a new command line owner that parses arguments/options and set them into the given object.CmdLineParser(java.lang.Object bean, Repository repo)
Creates a new command line owner that parses arguments/options and set them into the given object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
containsHelp(java.lang.String... args)
Check if array contains help optionprotected org.kohsuke.args4j.spi.OptionHandler
createOptionHandler(org.kohsuke.args4j.OptionDef o, org.kohsuke.args4j.spi.Setter setter)
Repository
getRepository()
Get the repository this parser translates values through.RevWalk
getRevWalk()
Get the revision walker used to support option parsing.RevWalk
getRevWalkGently()
Get the revision walker used to support option parsing.void
parseArgument(java.lang.String... args)
void
printSingleLineUsage(java.io.Writer w, java.util.ResourceBundle rb)
private void
printToErrorWriter(java.lang.String error)
private void
restoreRequiredOptions(java.util.List<org.kohsuke.args4j.spi.OptionHandler> backup)
private boolean
sortRestOfArgumentsHandlerToTheEnd(java.util.List<org.kohsuke.args4j.spi.OptionHandler> options)
private java.util.List<org.kohsuke.args4j.spi.OptionHandler>
unsetRequiredOptions()
-
Methods inherited from class org.kohsuke.args4j.CmdLineParser
addArgument, addOption, getArguments, getOptions, getProperties, isOption, parseArgument, printExample, printExample, printExample, printExample, printOption, printSingleLineUsage, printUsage, printUsage, printUsage, registerHandler, setUsageWidth, stopOptionParsing
-
-
-
-
Field Detail
-
db
private final Repository db
-
walk
private RevWalk walk
-
seenHelp
private boolean seenHelp
-
cmd
private TextBuiltin cmd
-
-
Constructor Detail
-
CmdLineParser
public CmdLineParser(java.lang.Object bean)
Creates a new command line owner that parses arguments/options and set them into the given object.- Parameters:
bean
- instance of a class annotated byOption
andArgument
. this object will receive values.- Throws:
org.kohsuke.args4j.IllegalAnnotationError
- if the option bean class is using args4j annotations incorrectly.
-
CmdLineParser
public CmdLineParser(java.lang.Object bean, Repository repo)
Creates a new command line owner that parses arguments/options and set them into the given object.- Parameters:
bean
- instance of a class annotated byOption
andArgument
. this object will receive values.repo
- repository this parser can translate options through.- Throws:
org.kohsuke.args4j.IllegalAnnotationError
- if the option bean class is using args4j annotations incorrectly.
-
-
Method Detail
-
parseArgument
public void parseArgument(java.lang.String... args) throws org.kohsuke.args4j.CmdLineException
- Overrides:
parseArgument
in classorg.kohsuke.args4j.CmdLineParser
- Throws:
org.kohsuke.args4j.CmdLineException
-
printToErrorWriter
private void printToErrorWriter(java.lang.String error)
-
unsetRequiredOptions
private java.util.List<org.kohsuke.args4j.spi.OptionHandler> unsetRequiredOptions()
-
restoreRequiredOptions
private void restoreRequiredOptions(java.util.List<org.kohsuke.args4j.spi.OptionHandler> backup)
-
containsHelp
protected boolean containsHelp(java.lang.String... args)
Check if array contains help option- Parameters:
args
- non null- Returns:
- true if the given array contains help option
- Since:
- 4.2
-
getRepository
public Repository getRepository()
Get the repository this parser translates values through.- Returns:
- the repository, if specified during construction.
-
getRevWalk
public RevWalk getRevWalk()
Get the revision walker used to support option parsing.- Returns:
- the revision walk used by this option parser.
-
getRevWalkGently
public RevWalk getRevWalkGently()
Get the revision walker used to support option parsing.This method does not initialize the RevWalk and may return null.
- Returns:
- the revision walk used by this option parser, or null.
-
createOptionHandler
protected org.kohsuke.args4j.spi.OptionHandler createOptionHandler(org.kohsuke.args4j.OptionDef o, org.kohsuke.args4j.spi.Setter setter)
- Overrides:
createOptionHandler
in classorg.kohsuke.args4j.CmdLineParser
-
printSingleLineUsage
public void printSingleLineUsage(java.io.Writer w, java.util.ResourceBundle rb)
- Overrides:
printSingleLineUsage
in classorg.kohsuke.args4j.CmdLineParser
-
sortRestOfArgumentsHandlerToTheEnd
private boolean sortRestOfArgumentsHandlerToTheEnd(java.util.List<org.kohsuke.args4j.spi.OptionHandler> options)
-
-