| | |
| | | * properties file, no-prompt etc. These will appear toward the bottom of |
| | | * the usage statement. |
| | | */ |
| | | private final ArgumentGroup ioArgGroup = new ArgumentGroup(INFO_DESCRIPTION_IO_ARGS.get(), |
| | | protected final ArgumentGroup ioArgGroup = new ArgumentGroup(INFO_DESCRIPTION_IO_ARGS.get(), |
| | | Integer.MIN_VALUE + 1); |
| | | |
| | | /** |
| | |
| | | * If the provided argument conflicts with another argument that |
| | | * has already been defined. |
| | | */ |
| | | void addDefaultArgument(final Argument argument) throws ArgumentException { |
| | | protected void addDefaultArgument(final Argument argument) throws ArgumentException { |
| | | addArgument(argument, defaultArgGroup); |
| | | } |
| | | |
| | |
| | | * If the provided argument conflicts with another argument that |
| | | * has already been defined. |
| | | */ |
| | | void addInputOutputArgument(final Argument argument) throws ArgumentException { |
| | | public void addInputOutputArgument(final Argument argument) throws ArgumentException { |
| | | addArgument(argument, ioArgGroup); |
| | | } |
| | | |
| | |
| | | * @return The argument with the specified long identifier, or |
| | | * <CODE>null</CODE> if there is no such argument. |
| | | */ |
| | | Argument getArgumentForLongID(final String longID) { |
| | | public Argument getArgumentForLongID(final String longID) { |
| | | return longIDMap.get(longID); |
| | | } |
| | | |
| | |
| | | * @return The list of all arguments that have been defined for this |
| | | * argument parser. |
| | | */ |
| | | LinkedList<Argument> getArgumentList() { |
| | | public LinkedList<Argument> getArgumentList() { |
| | | return argumentList; |
| | | } |
| | | |
| | |
| | | * @return A string containing usage information based on the defined |
| | | * arguments. |
| | | */ |
| | | String getUsage() { |
| | | public String getUsage() { |
| | | final StringBuilder buffer = new StringBuilder(); |
| | | getUsage(buffer); |
| | | |
| | |
| | | * @return <CODE>true</CODE> if the usage argument was provided and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | boolean isUsageArgumentPresent() { |
| | | public boolean isUsageArgumentPresent() { |
| | | boolean isUsageArgumentPresent = false; |
| | | if (usageArgument != null) { |
| | | isUsageArgumentPresent = usageArgument.isPresent(); |
| | |
| | | * @return <CODE>true</CODE> if the version argument was provided and |
| | | * <CODE>false</CODE> otherwise. |
| | | */ |
| | | boolean isVersionArgumentPresent() { |
| | | public boolean isVersionArgumentPresent() { |
| | | return versionPresent; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get the password which has to be used for the command without prompting the user. If no password was specified, |
| | | * return null. |
| | | * |
| | | * @param clearArg |
| | | * The password StringArgument argument. |
| | | * @param fileArg |
| | | * The password FileBased argument. |
| | | * @return The password stored into the specified file on by the command line argument, or null it if not specified. |
| | | */ |
| | | public static String getBindPassword(StringArgument clearArg, FileBasedArgument fileArg) { |
| | | if (clearArg.isPresent()) { |
| | | return clearArg.getValue(); |
| | | } else if (fileArg.isPresent()) { |
| | | return fileArg.getValue(); |
| | | } |
| | | return null; |
| | | } |
| | | } |