blob: 6956845f9bf0dab35ec4da468407905dd0095289 [file] [log] [blame]
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05001#include "handler.hpp"
2
3#include <CLI/CLI.hpp>
4
5int main(int argc, char** argv)
6{
7
8 CLI::App app{"PLDM requester tool for OpenBMC"};
9
10 // TODO: To enable it later
11 // bool verbose_flag = false;
12 // app.add_flag("-v, --verbose", verbose_flag, "Output debug logs ");
13 std::vector<std::string> args{};
14 app.add_option("-c, —command", args, "PLDM request command")->required();
15
16 std::string pldmCmdName;
17 app.add_option("GetPLDMTypes", pldmCmdName, "Get PLDM Type");
18 app.add_option("GetPLDMVersion", pldmCmdName, "Get PLDM Version");
19
20 app.add_subcommand("base", "PLDM Command Type = base");
21 app.add_subcommand("bios", "PLDM Command Type = bios");
22 app.add_subcommand("oem", "PLDM Command Type = oem");
23
24 CLI11_PARSE(app, argc, argv);
25
26 Handler handler;
27
28 // Parse args to program
29 std::string cmdName = args[0];
30 int rc = 0;
31
32 try
33 {
34 handler.dispatcher.at(cmdName)(std::move(args));
35 }
36 catch (const std::out_of_range& e)
37 {
38 std::cerr << cmdName << " is not supported!" << std::endl;
39 rc = -1;
40 }
41 return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
42}