← source index

main.cpp

38 lines  ·  778 B  ·  cpp
#include "Include.h"
#include "src/Log.h"
#include "src/Commands.h"

int main(int argc, char* argv[])
{
    Log& log = Log::getInstance();
    log.init("logs", "log.txt");

    std::string rawComm = "";

    for(int i = 1; i < argc; ++i)
    {
        rawComm += argv[i];

        if(i < argc - 1) rawComm += ' ';
    }

    Commands command;
    auto [status, err, normCmd, rawArgs, entireComm] = command.parseCommand(rawComm, true);

    if(!status && err.size() != 0)
    {
        log.error(err);
        std::cout << err << '\n';
        return -1;
    }

    auto [res_type, res, cmd] = command.runCommand(normCmd, rawArgs, entireComm);

    if(res_type != LogStatus::__NONE__)
    {
        std::cout << res << '\n';
        log.log(res_type, res);
    }

    return 0;
}