blob: 7e4e0e8d9ae3bc82aae94f72a45425cf20b5cce3 [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"
Sridevi Rameshd4489752019-12-08 09:03:29 -06004#include "pldm_fru_cmd.hpp"
George Liud6649362019-11-27 19:06:51 +08005#include "pldm_platform_cmd.hpp"
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -05006
7#include <CLI/CLI.hpp>
8
John Wang58a0e062019-11-08 15:38:15 +08009namespace pldmtool
10{
11
12namespace raw
13{
14
15using namespace pldmtool::helper;
16
17namespace
18{
19std::vector<std::unique_ptr<CommandInterface>> commands;
20}
21
22class RawOp : public CommandInterface
23{
24 public:
25 ~RawOp() = default;
26 RawOp() = delete;
27 RawOp(const RawOp&) = delete;
28 RawOp(RawOp&&) = default;
29 RawOp& operator=(const RawOp&) = delete;
30 RawOp& operator=(RawOp&&) = default;
31
32 explicit RawOp(const char* type, const char* name, CLI::App* app) :
33 CommandInterface(type, name, app)
34 {
35 app->add_option("-d,--data", rawData, "raw data")
36 ->required()
37 ->expected(-3);
38 }
39 std::pair<int, std::vector<uint8_t>> createRequestMsg() override
40
41 {
42 return {PLDM_SUCCESS, rawData};
43 }
44
45 void parseResponseMsg(pldm_msg* /* responsePtr */,
46 size_t /* payloadLength */) override
47 {
48 }
49
50 private:
51 std::vector<uint8_t> rawData;
52};
53
54void registerCommand(CLI::App& app)
55{
56 auto raw =
57 app.add_subcommand("raw", "send a raw request and print response");
58 commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
59}
60
61} // namespace raw
62} // namespace pldmtool
63
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050064int main(int argc, char** argv)
65{
66
67 CLI::App app{"PLDM requester tool for OpenBMC"};
John Wang58a0e062019-11-08 15:38:15 +080068 app.require_subcommand(1)->ignore_case();
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050069
John Wang58a0e062019-11-08 15:38:15 +080070 pldmtool::raw::registerCommand(app);
71 pldmtool::base::registerCommand(app);
Sridevi Ramesh98576432019-11-27 10:10:28 -060072 pldmtool::bios::registerCommand(app);
George Liud6649362019-11-27 19:06:51 +080073 pldmtool::platform::registerCommand(app);
Sridevi Rameshd4489752019-12-08 09:03:29 -060074 pldmtool::fru::registerCommand(app);
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050075
76 CLI11_PARSE(app, argc, argv);
John Wang58a0e062019-11-08 15:38:15 +080077 return 0;
Lakshminarayana R. Kammath27693a42019-06-24 00:51:47 -050078}