use of org.apache.ivy.util.cli.CommandLine in project ant-ivy by apache.
the class MainTest method testTypes.
/**
* Test case for IVY-1355.
* {@code types} argument to the command line must be parsed correctly when it's passed
* more than one value for the argument.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1355">IVY-1355</a>
*/
@Test
public void testTypes() throws Exception {
final String[] params = new String[] { "-settings", "test/repositories/ivysettings.xml", "-retrieve", "build/test/main/retrieve/[module]/[conf]/[artifact]-[revision].[ext]", "-types", "jar", "source" };
final CommandLine parsedCommand = Main.getParser().parse(params);
final String[] parsedTypes = parsedCommand.getOptionValues("types");
assertNotNull("Values for types argument is missing", parsedTypes);
assertEquals("Unexpected number of values parsed for types argument", 2, parsedTypes.length);
final Set<String> uniqueParsedTypes = new HashSet<>(Arrays.asList(parsedTypes));
assertTrue("jar type is missing from the parsed types argument", uniqueParsedTypes.contains("jar"));
assertTrue("jar type is missing from the parsed types argument", uniqueParsedTypes.contains("source"));
}
use of org.apache.ivy.util.cli.CommandLine in project ant-ivy by apache.
the class Main method run.
private static ResolveReport run(String[] args, boolean isCli) throws Exception {
CommandLineParser parser = getParser();
// parse the command line arguments
CommandLine line;
try {
line = parser.parse(args);
} catch (ParseException pe) {
// display usage and and rethrow
usage(parser, false);
throw new ParseException(pe.getMessage());
}
if (line.hasOption("?")) {
usage(parser, line.hasOption("deprecated"));
return null;
}
return run(line, isCli);
}
Aggregations