package com.redhat.ceylon.common.tool;

import java.util.List;

/**
 * Helper methods for tools
 * @author tom
 */
public class Tools {

    private Tools() {}
    
    public static boolean isFatal(Throwable t) {
        return t.getClass().getAnnotation(NonFatal.class) == null;
    }
    
    public static void printToolSuggestions(ToolLoader toolLoader, WordWrap wrap, String toolName) {
        
        wrap.append(ToolMessages.msg("tool.unknown", Tools.progName(), toolName)).newline();
        final List<String> suggestions = toolLoader.typo(toolName);
        if (suggestions != null 
                && !suggestions.isEmpty()) {
            wrap.newline();
            wrap.append(ToolMessages.msg("tool.unknown.suggest"));
            wrap.setIndent(4);
            wrap.newline();
            for (String suggestion : suggestions) {
                wrap.append(suggestion).newline();
            }
            wrap.newline();
        }
    }

    public static String progName() {
        return System.getProperty("com.redhat.ceylon.common.tool.progname", "ceylon");
    }

}

@@ -272,16 +272,180 @@
  == null
+%0A                // Dreadful hack to work around ceylon/ceylon-runtime#20%0A                && !t.getClass().getName().equals(%22ceylon.modules.CeylonRuntimeException%22)
 ;%0A    %7D%0A

Add a hack to work around issue described ceylon/ceylon-runtime#20