blob: bbbd4593beef3a5ea8a6675b323ec32020571083 [file] [log] [blame]
Brandon Wyman2ad76bd2019-08-26 17:15:04 -05001/**
2 * Copyright © 2019 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#include <CLI/CLI.hpp>
Brandon Wyman57939e82019-08-26 17:53:57 -050017#include <phosphor-logging/log.hpp>
18
19#include <filesystem>
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050020
21int main(int argc, char* argv[])
22{
Brandon Wyman57939e82019-08-26 17:53:57 -050023 using namespace phosphor::logging;
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050024
25 CLI::App app{"OpenBMC Power Supply Unit Monitor"};
Brandon Wyman57939e82019-08-26 17:53:57 -050026
27 std::string configfile;
28 app.add_option("-c,--config", configfile, "JSON configuration file path")
29 ->check(CLI::ExistingFile);
30
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050031 // Read the arguments.
32 CLI11_PARSE(app, argc, argv);
Brandon Wyman57939e82019-08-26 17:53:57 -050033 if (configfile.empty())
34 {
35 configfile = "/etc/phosphor-psu-monitor/psu_config.json";
36 }
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050037
Brandon Wyman57939e82019-08-26 17:53:57 -050038 if (!std::filesystem::exists(configfile))
39 {
40 log<level::ERR>("Configuration file does not exist",
41 entry("FILENAME=%s", configfile.c_str()));
42 return -1;
43 }
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050044
Brandon Wyman57939e82019-08-26 17:53:57 -050045 return 0;
Brandon Wyman2ad76bd2019-08-26 17:15:04 -050046}