-
Notifications
You must be signed in to change notification settings - Fork 22
/
dump_offload_main.cpp
46 lines (41 loc) · 1.1 KB
/
dump_offload_main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "argument.hpp"
#include "dump_offload.hpp"
#include <iostream>
#include <string>
static void ExitWithError(const char* err, char** argv)
{
phosphor::dump::util::ArgumentParser::usage(argv);
std::cerr << std::endl;
std::cerr << "ERROR: " << err << std::endl;
exit(EXIT_FAILURE);
}
int main(int argc, char** argv)
{
// Read arguments.
auto options = phosphor::dump::util::ArgumentParser(argc, argv);
std::string idStr = std::move((options)["id"]);
if (idStr.empty())
{
ExitWithError("Dump id is not provided", argv);
}
auto id = std::stoi(idStr);
std::filesystem::path path = std::move((options)["path"]);
if (path.empty())
{
ExitWithError("Dump file path not specified.", argv);
}
std::string uri = std::move((options)["uri"]);
if (path.empty())
{
ExitWithError("Dump offload uri not specified.", argv);
}
try
{
phosphor::dump::offload::requestOffload(path, id, uri);
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
}