blob: 1cc2894fad0b13cd881c1f921d51d6bfcfe8b2e6 [file] [log] [blame]
Brad Bishop29dbfa62016-12-19 13:39:57 -05001/**
2 * Copyright © 2016 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 */
Patrick Williams3667cf32015-10-20 22:39:11 -050016#include <iostream>
17#include <memory>
Matthew Barth6292aee2016-10-06 10:15:48 -050018#include "argument.hpp"
Brad Bishope55ef3d2016-12-19 09:12:40 -050019#include "mainloop.hpp"
Brad Bishopb9e2b072016-12-19 13:47:10 -050020#include "config.h"
Patrick Williams3667cf32015-10-20 22:39:11 -050021
22static void exit_with_error(const char* err, char** argv)
23{
24 ArgumentParser::usage(argv);
25 std::cerr << std::endl;
26 std::cerr << "ERROR: " << err << std::endl;
27 exit(-1);
28}
29
30int main(int argc, char** argv)
31{
32 // Read arguments.
33 auto options = std::make_unique<ArgumentParser>(argc, argv);
34
35 // Parse out path argument.
36 auto path = (*options)["path"];
37 if (path == ArgumentParser::empty_string)
38 {
39 exit_with_error("Path not specified.", argv);
40 }
41
Vishwanatha Subbanna52b80282016-12-02 23:58:55 +053042 // Finished getting options out, so cleanup the parser.
43 options.reset();
Patrick Williams3667cf32015-10-20 22:39:11 -050044
Brad Bishopb9e2b072016-12-19 13:47:10 -050045 MainLoop loop(
Brad Bishop9c7b6e02016-12-19 12:43:36 -050046 sdbusplus::bus::new_default(),
Brad Bishopb9e2b072016-12-19 13:47:10 -050047 path,
48 BUSNAME_PREFIX,
49 SENSOR_ROOT);
Brad Bishopd499ca62016-12-19 09:24:50 -050050 loop.run();
51
52 return 0;
Patrick Williams3667cf32015-10-20 22:39:11 -050053}
54
Brad Bishop03476f12016-12-19 13:09:12 -050055// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4