package me.km.snuviscript.commands;

import me.hammerle.snuviscript.code.ScriptManager;
import me.km.snuviscript.SnuviLogger;

public class ErrorCommands {
    public static void registerFunctions(ScriptManager sm) {
        sm.registerConsumer("error.clear", (sc, in) -> {
            ((SnuviLogger) sm.getLogger()).getErrorHistory().clear();
        });
        sm.registerFunction("error.getsize", (sc, in) -> {
            return (double) ((SnuviLogger) sm.getLogger()).getErrorHistory().getLength();
        });
        sm.registerFunction("error.getindex", (sc, in) -> {
            return ((SnuviLogger) sm.getLogger()).getErrorHistory().get(in[0].getInt(sc));
        });
        sm.registerConsumer("error.setconsoleprint", (sc, in) -> {
            ((SnuviLogger) sm.getLogger()).setConsoleErrorLogging(in[0].getBoolean(sc));
        });
        sm.registerConsumer("debug.clear", (sc, in) -> {
            ((SnuviLogger) sm.getLogger()).getDebugHistory().clear();
        });
        sm.registerFunction("debug.getsize", (sc, in) -> {
            return (double) ((SnuviLogger) sm.getLogger()).getDebugHistory().getLength();
        });
        sm.registerFunction("debug.getindex", (sc, in) -> {
            return ((SnuviLogger) sm.getLogger()).getDebugHistory().get(in[0].getInt(sc));
        });
        sm.registerConsumer("debug.setconsoleprint", (sc, in) -> {
            ((SnuviLogger) sm.getLogger()).setConsoleDebugLogging(in[0].getBoolean(sc));
        });
    }
}
