John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 1 | #include "pldm_base_cmd.hpp" |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 2 | #include "pldm_bios_cmd.hpp" |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 3 | #include "pldm_cmd_helper.hpp" |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 4 | #include "pldm_fru_cmd.hpp" |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 5 | #include "pldm_platform_cmd.hpp" |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 6 | |
| 7 | #include <CLI/CLI.hpp> |
| 8 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 9 | namespace pldmtool |
| 10 | { |
| 11 | |
| 12 | namespace raw |
| 13 | { |
| 14 | |
| 15 | using namespace pldmtool::helper; |
| 16 | |
| 17 | namespace |
| 18 | { |
| 19 | std::vector<std::unique_ptr<CommandInterface>> commands; |
| 20 | } |
| 21 | |
| 22 | class 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 | |
| 54 | void 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. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 64 | int main(int argc, char** argv) |
| 65 | { |
| 66 | |
| 67 | CLI::App app{"PLDM requester tool for OpenBMC"}; |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 68 | app.require_subcommand(1)->ignore_case(); |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 69 | |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 70 | pldmtool::raw::registerCommand(app); |
| 71 | pldmtool::base::registerCommand(app); |
Sridevi Ramesh | 9857643 | 2019-11-27 10:10:28 -0600 | [diff] [blame] | 72 | pldmtool::bios::registerCommand(app); |
George Liu | d664936 | 2019-11-27 19:06:51 +0800 | [diff] [blame] | 73 | pldmtool::platform::registerCommand(app); |
Sridevi Ramesh | d448975 | 2019-12-08 09:03:29 -0600 | [diff] [blame] | 74 | pldmtool::fru::registerCommand(app); |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 75 | |
| 76 | CLI11_PARSE(app, argc, argv); |
John Wang | 58a0e06 | 2019-11-08 15:38:15 +0800 | [diff] [blame] | 77 | return 0; |
Lakshminarayana R. Kammath | 27693a4 | 2019-06-24 00:51:47 -0500 | [diff] [blame] | 78 | } |