blob: 0f0182b72a9cd1bb8764b5b1dec16f695ed1faf7 [file] [log] [blame]
John Wang58a0e062019-11-08 15:38:15 +08001#include "pldm_base_cmd.hpp"
Sridevi Ramesh98576432019-11-27 10:10:28 -06002#include "pldm_bios_cmd.hpp"
John Wang58a0e062019-11-08 15:38:15 +08003#include "pldm_cmd_helper.hpp"
George Liud6649362019-11-27 19:06:51 +08004#include "pldm_platform_cmd.hpp"
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05005
6#include <CLI/CLI.hpp>
7
John Wang58a0e062019-11-08 15:38:15 +08008namespace pldmtool
9{
10
11namespace raw
12{
13
14using namespace pldmtool::helper;
15
16namespace
17{
18std::vector<std::unique_ptr<CommandInterface>> commands;
19}
20
21class RawOp : public CommandInterface
22{
23 public:
24 ~RawOp() = default;
25 RawOp() = delete;
26 RawOp(const RawOp&) = delete;
27 RawOp(RawOp&&) = default;
28 RawOp& operator=(const RawOp&) = delete;
29 RawOp& operator=(RawOp&&) = default;
30
31 explicit RawOp(const char* type, const char* name, CLI::App* app) :
32 CommandInterface(type, name, app)
33 {
34 app->add_option("-d,--data", rawData, "raw data")
35 ->required()
36 ->expected(-3);
37 }
38 std::pair<int, std::vector<uint8_t>> createRequestMsg() override
39
40 {
41 return {PLDM_SUCCESS, rawData};
42 }
43
44 void parseResponseMsg(pldm_msg* /* responsePtr */,
45 size_t /* payloadLength */) override
46 {
47 }
48
49 private:
50 std::vector<uint8_t> rawData;
51};
52
53void registerCommand(CLI::App& app)
54{
55 auto raw =
56 app.add_subcommand("raw", "send a raw request and print response");
57 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
58}
59
60} // namespace raw
61} // namespace pldmtool
62
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050063int main(int argc, char** argv)
64{
65
66 CLI::App app{"PLDM requester tool for OpenBMC"};
John Wang58a0e062019-11-08 15:38:15 +080067 app.require_subcommand(1)->ignore_case();
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050068
John Wang58a0e062019-11-08 15:38:15 +080069 pldmtool::raw::registerCommand(app);
70 pldmtool::base::registerCommand(app);
Sridevi Ramesh98576432019-11-27 10:10:28 -060071 pldmtool::bios::registerCommand(app);
George Liud6649362019-11-27 19:06:51 +080072 pldmtool::platform::registerCommand(app);
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050073
74 CLI11_PARSE(app, argc, argv);
John Wang58a0e062019-11-08 15:38:15 +080075 return 0;
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050076}