blob: 059bd8e707d02cca340c3c80f35acfcd1aadf82f [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"
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05004
5#include <CLI/CLI.hpp>
6
John Wang58a0e062019-11-08 15:38:15 +08007namespace pldmtool
8{
9
10namespace raw
11{
12
13using namespace pldmtool::helper;
14
15namespace
16{
17std::vector<std::unique_ptr<CommandInterface>> commands;
18}
19
20class RawOp : public CommandInterface
21{
22 public:
23 ~RawOp() = default;
24 RawOp() = delete;
25 RawOp(const RawOp&) = delete;
26 RawOp(RawOp&&) = default;
27 RawOp& operator=(const RawOp&) = delete;
28 RawOp& operator=(RawOp&&) = default;
29
30 explicit RawOp(const char* type, const char* name, CLI::App* app) :
31 CommandInterface(type, name, app)
32 {
33 app->add_option("-d,--data", rawData, "raw data")
34 ->required()
35 ->expected(-3);
36 }
37 std::pair<int, std::vector<uint8_t>> createRequestMsg() override
38
39 {
40 return {PLDM_SUCCESS, rawData};
41 }
42
43 void parseResponseMsg(pldm_msg* /* responsePtr */,
44 size_t /* payloadLength */) override
45 {
46 }
47
48 private:
49 std::vector<uint8_t> rawData;
50};
51
52void registerCommand(CLI::App& app)
53{
54 auto raw =
55 app.add_subcommand("raw", "send a raw request and print response");
56 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
57}
58
59} // namespace raw
60} // namespace pldmtool
61
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050062int main(int argc, char** argv)
63{
64
65 CLI::App app{"PLDM requester tool for OpenBMC"};
John Wang58a0e062019-11-08 15:38:15 +080066 app.require_subcommand(1)->ignore_case();
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050067
John Wang58a0e062019-11-08 15:38:15 +080068 pldmtool::raw::registerCommand(app);
69 pldmtool::base::registerCommand(app);
Sridevi Ramesh98576432019-11-27 10:10:28 -060070 pldmtool::bios::registerCommand(app);
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050071
72 CLI11_PARSE(app, argc, argv);
John Wang58a0e062019-11-08 15:38:15 +080073 return 0;
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050074}