Search in sources :

Example 1 with ToolInitializationException

use of org.eclipse.ceylon.common.tool.OptionArgumentException.ToolInitializationException 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)

Aggregations

ArgumentMultiplicityException (org.eclipse.ceylon.common.tool.OptionArgumentException.ArgumentMultiplicityException)1 InvalidArgumentValueException (org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidArgumentValueException)1 InvalidOptionValueException (org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException)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