blob: bbe2a8567e93c02d395df9006996906fd46290c3 [file] [log] [blame]
Jayanth Othayoth0aa0d112018-09-03 03:47:27 -05001/**
2 * Copyright © 2018 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "argument.hpp"
18
19#include <iostream>
20#include <string>
21
22static void ExitWithError(const char* err, char** argv)
23{
24 phosphor::certs::util::ArgumentParser::usage(argv);
25 std::cerr << std::endl;
26 std::cerr << "ERROR: " << err << std::endl;
27 exit(EXIT_FAILURE);
28}
29
30int main(int argc, char** argv)
31{
32 // Read arguments.
33 auto options = phosphor::certs::util::ArgumentParser(argc, argv);
34
35 // Parse arguments
36 auto type = std::move((options)["type"]);
37 if (type == phosphor::certs::util::ArgumentParser::empty_string)
38 {
39 ExitWithError("type not specified.", argv);
40 }
41
42 auto endpoint = std::move((options)["endpoint"]);
43 if (endpoint == phosphor::certs::util::ArgumentParser::empty_string)
44 {
45 ExitWithError("endpoint not specified.", argv);
46 }
47
48 auto path = std::move((options)["path"]);
49 if (path == phosphor::certs::util::ArgumentParser::empty_string)
50 {
51 ExitWithError("path not specified.", argv);
52 }
53
54 // unit is an optional parametr
55 auto unit = std::move((options)["unit"]);
56
57 return 0;
58}