public class Flags extends Object
initForTesting(Map)).
Example:
{@code| Modifier and Type | Method and Description |
|---|---|
com.github.yin.flags.Flags.ArgumentIndex |
arguments()
Returns an
ArgumentIndex instance used to query for argument values. |
static void |
clear()
Clears the argument values.
|
static <T> Flag<T> |
create(Class<T> type,
String name)
Returns flag value accessor, which can be used to retrieve the actual flag value supplied
by command line arguments or by other mechanism (such as
initForTesting()). |
TypeConversion |
getTypeConversion()
Type conversions used by Flags.
|
static void |
init(String[] args)
Initializes flag values from command-line style arguments.
|
static void |
initForTesting(Map<String,String> options)
Indexes flag values from a
Map. |
static void |
printUsage(String packagePrefix)
Prints user-readable usage help for all flags in a given package
|
static Flag<String> |
string(String name)
Returns flag value accessor for
String type. |
public static void init(String[] args)
args - command-line arguments to parse values frompublic static Flag<String> string(String name)
String type. See create().public static <T> Flag<T> create(Class<T> type, String name)
initForTesting()).
Preferably the typespecific variants (string(), ...) should be used for
readability reasons.
&at;FlagDesc("Specifies path to input file")
private static final Flag<String> flag_inputPath = Flags.create(String.class, "inputPath");
T - is the same as flag value typetype - of the provided flag valuename - of the flag. This is must match the name the field or name attribute in @FlagDesc annotation.namepublic static void printUsage(String packagePrefix)
public static void initForTesting(Map<String,String> options)
Map. This is useful for mocking flag values in
integration testing. Please do not misuse this function, there will be better way to inject
your logic into flag processing, surely use this only in your tests.options - Map of flags and their intended valuespublic static void clear()
public com.github.yin.flags.Flags.ArgumentIndex arguments()
ArgumentIndex instance used to query for argument values.public TypeConversion getTypeConversion()
Copyright © 2016. All rights reserved.