#include <DevCommand/WCreateCommand/WCreateCommand.hpp>
#include <Log/Log.hpp>
#include <AtomicDataStore/AtomicDataStore.hpp>

int WCreateCommand::execute(const std::vector<std::string> &args)
{
    if (args.size() != 3)
    {
        Log::error("Syntax: wcreate <filename>");
        return 1;
    }

    std::string path = args[2];
    AtomicDataStore store;
    if (store.create(path))
    {
        AtomicDataStore::Plan init;
        store.update(init, 0);

        Log::info("Empty world file created successfully.");
        return 0;
    }
    else
    {
        Log::error("Failed to create the world file.");
        return 1;
    }
}