Search in sources :

Example 1 with InvalidOptionValueException

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();
}
Also used : ArgumentMultiplicityException(org.eclipse.ceylon.common.tool.OptionArgumentException.ArgumentMultiplicityException) UnknownOptionException(org.eclipse.ceylon.common.tool.OptionArgumentException.UnknownOptionException) InvalidArgumentValueException(org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidArgumentValueException) OptionWithoutArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException.OptionWithoutArgumentException) ToolInitializationException(org.eclipse.ceylon.common.tool.OptionArgumentException.ToolInitializationException) OptionMultiplicityException(org.eclipse.ceylon.common.tool.OptionArgumentException.OptionMultiplicityException) InvalidOptionValueException(org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException)

Example 2 with InvalidOptionValueException

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());
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) InvalidOptionValueException(org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException) Test(org.junit.Test)

Aggregations

InvalidOptionValueException (org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException)2 ArgumentMultiplicityException (org.eclipse.ceylon.common.tool.OptionArgumentException.ArgumentMultiplicityException)1 InvalidArgumentValueException (org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidArgumentValueException)1 OptionMultiplicityException (org.eclipse.ceylon.common.tool.OptionArgumentException.OptionMultiplicityException)1 OptionWithoutArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException.OptionWithoutArgumentException)1 ToolInitializationException (org.eclipse.ceylon.common.tool.OptionArgumentException.ToolInitializationException)1 UnknownOptionException (org.eclipse.ceylon.common.tool.OptionArgumentException.UnknownOptionException)1 CeylonCompileTool (org.eclipse.ceylon.compiler.CeylonCompileTool)1 Test (org.junit.Test)1