Brad Bishop | 29dbfa6 | 2016-12-19 13:39:57 -0500 | [diff] [blame] | 1 | /** |
| 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 Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 16 | #include <iostream> |
| 17 | #include <memory> |
Matthew Barth | 6292aee | 2016-10-06 10:15:48 -0500 | [diff] [blame] | 18 | #include "argument.hpp" |
Brad Bishop | e55ef3d | 2016-12-19 09:12:40 -0500 | [diff] [blame] | 19 | #include "mainloop.hpp" |
Brad Bishop | b9e2b07 | 2016-12-19 13:47:10 -0500 | [diff] [blame] | 20 | #include "config.h" |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 21 | |
| 22 | static 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 | |
| 30 | int 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 Subbanna | 52b8028 | 2016-12-02 23:58:55 +0530 | [diff] [blame] | 42 | // Finished getting options out, so cleanup the parser. |
| 43 | options.reset(); |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 44 | |
Brad Bishop | b9e2b07 | 2016-12-19 13:47:10 -0500 | [diff] [blame] | 45 | MainLoop loop( |
Brad Bishop | 9c7b6e0 | 2016-12-19 12:43:36 -0500 | [diff] [blame] | 46 | sdbusplus::bus::new_default(), |
Brad Bishop | b9e2b07 | 2016-12-19 13:47:10 -0500 | [diff] [blame] | 47 | path, |
| 48 | BUSNAME_PREFIX, |
| 49 | SENSOR_ROOT); |
Brad Bishop | d499ca6 | 2016-12-19 09:24:50 -0500 | [diff] [blame] | 50 | loop.run(); |
| 51 | |
| 52 | return 0; |
Patrick Williams | 3667cf3 | 2015-10-20 22:39:11 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Brad Bishop | 03476f1 | 2016-12-19 13:09:12 -0500 | [diff] [blame] | 55 | // vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 |