1 #include "argument.hpp"
2
3 #include "certificate.hpp"
4
5 #include <CLI/CLI.hpp>
6
7 namespace phosphor::certs
8 {
9
processArguments(int argc,const char * const * argv,Arguments & arguments)10 int processArguments(int argc, const char* const* argv, Arguments& arguments)
11 {
12 CLI::App app{"OpenBMC Certificate Management Daemon"};
13 app.add_option("-t,--type", arguments.typeStr, "certificate type")
14 ->required();
15 app.add_option("-e,--endpoint", arguments.endpoint, "d-bus endpoint")
16 ->required();
17 app.add_option("-p,--path", arguments.path, "certificate file path")
18 ->required();
19 app.add_option("-u,--unit", arguments.unit,
20 "Optional systemd unit need to reload")
21 ->capture_default_str();
22 CLI11_PARSE(app, argc, argv);
23 phosphor::certs::CertificateType type =
24 phosphor::certs::stringToCertificateType(arguments.typeStr);
25 if (type == phosphor::certs::CertificateType::unsupported)
26 {
27 std::cerr << "type not specified or invalid." << std::endl;
28 return 1;
29 }
30 return 0;
31 }
32 } // namespace phosphor::certs
33