blob: 19aeb6afce8be49e24c390d7fe94f1f659698536 [file] [log] [blame]
Vishwanatha Subbanna15b1dc12017-05-23 15:16:13 +05301/**
2 * Copyright © 2017 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 <iostream>
18#include "argument.hpp"
19
20static void exitWithError(const char* err, char** argv)
21{
22 phosphor::watchdog::ArgumentParser::usage(argv);
23 std::cerr << "ERROR: " << err << "\n";
24 exit(EXIT_FAILURE);
25}
26
27int main(int argc, char** argv)
28{
29 // Read arguments.
30 auto options = phosphor::watchdog::ArgumentParser(argc, argv);
31
32 // Parse out path argument.
33 auto path = (options)["path"];
34 if (path == phosphor::watchdog::ArgumentParser::emptyString)
35 {
36 exitWithError("Path not specified.", argv);
37 }
38
39 // Parse out service name argument
40 auto service = (options)["service"];
41 if (service == phosphor::watchdog::ArgumentParser::emptyString)
42 {
43 exitWithError("Service not specified.", argv);
44 }
45
46 // Parse out target argument. It is fine if the caller does not
47 // pass this if they are not interested in calling into any target
48 // on meeting a condition.
49 auto target = (options)["target"];
50
51 return 0;
52}