Andrew Geissler | ee3a2c8 | 2019-07-30 15:16:20 -0500 | [diff] [blame^] | 1 | #include <CLI/CLI.hpp> |
| 2 | #include <iostream> |
| 3 | #include <phosphor-logging/log.hpp> |
Andrew Geissler | 891213b | 2019-07-30 14:08:17 -0500 | [diff] [blame] | 4 | #include <sdbusplus/bus.hpp> |
| 5 | #include <sdeventplus/event.hpp> |
Andrew Geissler | ee3a2c8 | 2019-07-30 15:16:20 -0500 | [diff] [blame^] | 6 | #include <vector> |
| 7 | |
| 8 | using phosphor::logging::level; |
| 9 | using phosphor::logging::log; |
| 10 | |
| 11 | void print_usage(void) |
| 12 | { |
| 13 | std::cout << "[-f <file1> -f <file2> ...] : Full path to json file(s) with " |
| 14 | "target/error mappings" |
| 15 | << std::endl; |
| 16 | return; |
| 17 | } |
Andrew Geissler | 891213b | 2019-07-30 14:08:17 -0500 | [diff] [blame] | 18 | |
| 19 | int main(int argc, char* argv[]) |
| 20 | { |
| 21 | auto bus = sdbusplus::bus::new_default(); |
| 22 | auto event = sdeventplus::Event::get_default(); |
| 23 | bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); |
Andrew Geissler | ee3a2c8 | 2019-07-30 15:16:20 -0500 | [diff] [blame^] | 24 | std::vector<std::string> filePaths; |
Andrew Geissler | 891213b | 2019-07-30 14:08:17 -0500 | [diff] [blame] | 25 | |
Andrew Geissler | ee3a2c8 | 2019-07-30 15:16:20 -0500 | [diff] [blame^] | 26 | CLI::App app{"OpenBmc systemd target monitor"}; |
| 27 | app.add_option("-f,--file", filePaths, |
| 28 | "Full path to json file(s) with target/error mappings"); |
| 29 | |
| 30 | CLI11_PARSE(app, argc, argv); |
| 31 | |
| 32 | if (filePaths.empty()) |
| 33 | { |
| 34 | log<level::ERR>("No input files"); |
| 35 | print_usage(); |
| 36 | exit(-1); |
| 37 | } |
Andrew Geissler | 891213b | 2019-07-30 14:08:17 -0500 | [diff] [blame] | 38 | |
| 39 | // TODO - Load in json config file(s) |
| 40 | |
| 41 | // TODO - Begin monitoring for systemd unit changes and logging appropriate |
| 42 | // errors |
| 43 | |
| 44 | return event.loop(); |
| 45 | } |