blob: 7244e4708d1056cf81446633116075772e51c76e [file] [log] [blame]
#include "pldm_base_cmd.hpp"
#include "pldm_cmd_helper.hpp"
#include <CLI/CLI.hpp>
namespace pldmtool
{
namespace raw
{
using namespace pldmtool::helper;
namespace
{
std::vector<std::unique_ptr<CommandInterface>> commands;
}
class RawOp : public CommandInterface
{
public:
~RawOp() = default;
RawOp() = delete;
RawOp(const RawOp&) = delete;
RawOp(RawOp&&) = default;
RawOp& operator=(const RawOp&) = delete;
RawOp& operator=(RawOp&&) = default;
explicit RawOp(const char* type, const char* name, CLI::App* app) :
CommandInterface(type, name, app)
{
app->add_option("-d,--data", rawData, "raw data")
->required()
->expected(-3);
}
std::pair<int, std::vector<uint8_t>> createRequestMsg() override
{
return {PLDM_SUCCESS, rawData};
}
void parseResponseMsg(pldm_msg* /* responsePtr */,
size_t /* payloadLength */) override
{
}
private:
std::vector<uint8_t> rawData;
};
void registerCommand(CLI::App& app)
{
auto raw =
app.add_subcommand("raw", "send a raw request and print response");
commands.push_back(std::make_unique<RawOp>("raw", "raw", raw));
}
} // namespace raw
} // namespace pldmtool
int main(int argc, char** argv)
{
CLI::App app{"PLDM requester tool for OpenBMC"};
app.require_subcommand(1)->ignore_case();
pldmtool::raw::registerCommand(app);
pldmtool::base::registerCommand(app);
CLI11_PARSE(app, argc, argv);
return 0;
}