#include "file-io.hpp"

#include <stdplus/print.hpp>

#include <cstring>
#include <iostream>

static void printUsage()
{
    stdplus::println(stderr, "Usage: update_dhcp_status <state> <message>");
    stdplus::println(stderr,
                     "<state> is one of 'DONE', 'POWERCYCLE' or 'ONGOING'");
}

static int genStatusCode(char* state)
{
    if (std::strcmp(state, "DONE") == 0)
    {
        return 0;
    }
    else if (std::strcmp(state, "POWERCYCLE") == 0)
    {
        return 1;
    }
    else if (std::strcmp(state, "ONGOING") == 0)
    {
        return 2;
    }

    return -1;
}

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        printUsage();
        return 1;
    }

    int statusCode = genStatusCode(argv[1]);

    if (statusCode == -1)
    {
        printUsage();
        return 1;
    }

    try
    {
        std::string status;
        status.push_back(statusCode);
        status.append(argv[2]);
        fileWrite(statusFile, status);
    }
    catch (const std::exception& e)
    {
        stdplus::println(stderr, "Failed to update status file {}", e.what());
        return 1;
    }

    return 0;
}
