blob: 6956845f9bf0dab35ec4da468407905dd0095289 [file] [log] [blame]
#include "handler.hpp"
#include <CLI/CLI.hpp>
int main(int argc, char** argv)
{
CLI::App app{"PLDM requester tool for OpenBMC"};
// TODO: To enable it later
// bool verbose_flag = false;
// app.add_flag("-v, --verbose", verbose_flag, "Output debug logs ");
std::vector<std::string> args{};
app.add_option("-c, —command", args, "PLDM request command")->required();
std::string pldmCmdName;
app.add_option("GetPLDMTypes", pldmCmdName, "Get PLDM Type");
app.add_option("GetPLDMVersion", pldmCmdName, "Get PLDM Version");
app.add_subcommand("base", "PLDM Command Type = base");
app.add_subcommand("bios", "PLDM Command Type = bios");
app.add_subcommand("oem", "PLDM Command Type = oem");
CLI11_PARSE(app, argc, argv);
Handler handler;
// Parse args to program
std::string cmdName = args[0];
int rc = 0;
try
{
handler.dispatcher.at(cmdName)(std::move(args));
}
catch (const std::out_of_range& e)
{
std::cerr << cmdName << " is not supported!" << std::endl;
rc = -1;
}
return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
}