private static String parseValue(final String arg, final String key) { int splitPos = key.length(); if (arg.length() <= splitPos + 1 || arg.charAt(splitPos) != '=') { System.err.println(MESSAGES.argumentHasNoValue(arg, usageNote())); return null; } else { return arg.substring(splitPos + 1); } }
/** * Validates that param {@code value} does not begin with the character {@code -}. For use in cases where * the legal value for an argument would not begin with that character. Usage is to detect missing argument * values, where the command line includes another argument instead of the value for the last argument. * * @param argument the last argument, whose value should be {@code value} * @param value the next item in the command line arguments, which should be the value for {@code argument} * @return {@code value} if it is valid, or {@code null} if it is not */ private static String checkValueIsNotAnArg(String argument, String value) { if (value.startsWith("-")) { System.err.println(MESSAGES.argumentHasNoValue(argument, usageNote())); return null; } return value; }