use of org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException in project ceylon by eclipse.
the class Usage method printUsage.
private void printUsage(OptionArgumentException t) throws Exception {
// which isn't part of the tool API
if (t instanceof UnknownOptionException) {
UnknownOptionException e = (UnknownOptionException) t;
printSynopsis(e.getToolModel());
printOptionSuggestions(e);
} else if (t instanceof OptionMultiplicityException) {
OptionMultiplicityException e = (OptionMultiplicityException) t;
printSynopsis(e.getToolModel());
printOptions(e.getOptionModel().getLongName());
} else if (t instanceof ArgumentMultiplicityException) {
ArgumentMultiplicityException e = (ArgumentMultiplicityException) t;
printSynopsis(e.getToolModel());
} else if (t instanceof OptionWithoutArgumentException) {
OptionWithoutArgumentException e = (OptionWithoutArgumentException) t;
printSynopsis(e.getToolModel());
printOptions(e.getOptionModel().getLongName());
printSuggestions(e.getOptionModel().getArgument().getParser(), null);
} else if (t instanceof InvalidArgumentValueException) {
InvalidArgumentValueException e = (InvalidArgumentValueException) t;
printSynopsis(e.getToolModel());
printSuggestions(e.getArgumentModel().getParser(), e.getBadValue());
} else if (t instanceof InvalidOptionValueException) {
InvalidOptionValueException e = (InvalidOptionValueException) t;
printSynopsis(e.getToolModel());
printOptions(e.getOptionModel().getLongName());
printSuggestions(e.getOptionModel().getArgument().getParser(), e.getBadValue());
} else if (t instanceof ToolInitializationException) {
ToolInitializationException e = (ToolInitializationException) t;
printSynopsis(e.getToolModel());
} else {
printSynopsis(null);
}
printHelpInvocation();
}
use of org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException in project ceylon by eclipse.
the class CompilerToolTests method testTargetInvalid.
@Test
public void testTargetInvalid() throws Exception {
ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
Assert.assertNotNull(model);
try {
CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "--target=56", "org.eclipse.ceylon.tools.test.java8"));
} catch (InvalidOptionValueException e) {
Assert.assertEquals("Invalid value '56' given for option 'target' to command 'compile'", e.getMessage());
}
}
Aggregations