Package org.opengrok.indexer.util
Class Getopt
java.lang.Object
org.opengrok.indexer.util.Getopt
A simple implementation of the getopt(3c). It does just implement what I
need ;-) Please note that I dislike the way GNU getopt allows mixing of
options and arguments, so this version will stop processing options as soon
as it encounters an argument.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Getopt
Creates a new instance of Getopt.- Parameters:
argv
- argument vectoropts
- the list of allowed options
-
-
Method Details
-
parse
Parse the command line options.- Throws:
ParseException
- if an illegal argument is passed
-
getOpt
public int getOpt()Get the next option in the options string.- Returns:
- the next valid option, or -1 if all options are processed
-
reset
public void reset()Reset the current pointer so we may traverse all the options again. -
getOptarg
Get the argument to the current option.- Returns:
- the argument or null if none present (or allowed)
-
getOptind
public int getOptind()Get the index of the first argument.- Returns:
- the index of the first argument in the original array
-