#include <Bitmap/Bitmap.hpp>
#include <DevCommand/MkWorldCommand/MkWorldCommand.hpp>
#include <DevCommand/TerrainDumpCommand/TerrainDumpCommand.hpp>
#include <DevCommand/WCloneCommand/WCloneCommand.hpp>
#include <DevCommand/WCreateCommand/WCreateCommand.hpp>
#include <DevCommand/WDumpCommand/WDumpCommand.hpp>
#include <DevCommand/WImportDirCommand/WImportDirCommand.hpp>
#include <DevCommand/WRepackCommand/WRepackCommand.hpp>
#include <DevCommand/WScriptCommand/WScriptCommand.hpp>
#include <DevCommand/WSetVersionCommand/WSetVersionCommand.hpp>
#include <DevCommand/WTestCommand/WTestCommand.hpp>
#include <DevCommand/WUnpackCommand/WUnpackCommand.hpp>
#include <Log/Log.hpp>
#include <VoxelverseSession/VoxelverseDevTool/VoxelverseDevTool.hpp>

VoxelverseDevTool::VoxelverseDevTool()
{
    registerCommand<WCreateCommand>("wcreate");
    registerCommand<WImportDirCommand>("wimportdir");
    registerCommand<WDumpCommand>("wdump");
    registerCommand<WUnpackCommand>("wunpack");
    registerCommand<WSetVersionCommand>("wsetversion");
    registerCommand<WTestCommand>("wtest");
    registerCommand<TerrainDumpCommand>("terraindump");
    registerCommand<MkWorldCommand>("mkworld");
    registerCommand<WCloneCommand>("wclone");
    registerCommand<WRepackCommand>("wrepack");
    registerCommand<WScriptCommand>("wscript");
}

int VoxelverseDevTool::run()
{
    if (args.size() < 2)
    {
        Log::error("No command specified.");
        return 1;
    }

    const std::string &cmd = args[1];

    auto it = commands.find(cmd);
    if (it == commands.end())
    {
        Log::error(formatString("Unknown command '$+'", cmd));
        return 1;
    }

    return it->second->execute(args);
}

std::string VoxelverseDevTool::getSessionTypeName()
{
    return "devtool";
}