Gunnar Mills | 7263915 | 2017-06-22 15:06:21 -0500 | [diff] [blame] | 1 | #include <iostream> |
| 2 | #include <phosphor-logging/log.hpp> |
| 3 | #include "argument.hpp" |
| 4 | #include "gpio_presence.hpp" |
| 5 | |
| 6 | using namespace phosphor::logging; |
| 7 | using namespace phosphor::gpio; |
Gunnar Mills | 5f10110 | 2017-06-29 13:07:39 -0500 | [diff] [blame] | 8 | using namespace phosphor::gpio::presence; |
Gunnar Mills | 7263915 | 2017-06-22 15:06:21 -0500 | [diff] [blame] | 9 | |
| 10 | int main(int argc, char* argv[]) |
| 11 | { |
| 12 | auto options = ArgumentParser(argc, argv); |
| 13 | |
| 14 | auto inventory = options["inventory"]; |
| 15 | auto key = options["key"]; |
| 16 | auto path = options["path"]; |
| 17 | if (argc < 4) |
| 18 | { |
| 19 | std::cerr << "Too few arguments\n"; |
| 20 | options.usage(argv); |
| 21 | } |
| 22 | |
| 23 | if (inventory == ArgumentParser::emptyString) |
| 24 | { |
| 25 | std::cerr << "Inventory argument required\n"; |
| 26 | options.usage(argv); |
| 27 | } |
| 28 | |
| 29 | if (key == ArgumentParser::emptyString) |
| 30 | { |
| 31 | std::cerr << "GPIO key argument required\n"; |
| 32 | options.usage(argv); |
| 33 | } |
| 34 | |
| 35 | if (path == ArgumentParser::emptyString) |
| 36 | { |
| 37 | std::cerr << "Device path argument required\n"; |
| 38 | options.usage(argv); |
| 39 | } |
Gunnar Mills | 80292bb | 2017-07-05 16:34:51 -0500 | [diff] [blame^] | 40 | |
| 41 | auto bus = sdbusplus::bus::new_default(); |
| 42 | auto name = options["name"]; |
| 43 | Presence presence(bus, inventory, path, std::stoul(key), name); |
Gunnar Mills | 7263915 | 2017-06-22 15:06:21 -0500 | [diff] [blame] | 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |