led-manager: add CLI11 option and config loading
To facilitate localized testing of JSON config loading, add an option
that allows the configuration to be directly passed, rather than try to
determine it from entity-manager config off dbus.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I80d7051bf312044c68f44bcdb9ac02364f9abac3
diff --git a/manager/led-main.cpp b/manager/led-main.cpp
index c3b2cea..8861a64 100644
--- a/manager/led-main.cpp
+++ b/manager/led-main.cpp
@@ -14,13 +14,23 @@
#include "lamptest/lamptest.hpp"
#endif
+#include <CLI/CLI.hpp>
#include <sdeventplus/event.hpp>
#include <algorithm>
#include <iostream>
-int main(void)
+int main(int argc, char** argv)
{
+ CLI::App app("phosphor-led-manager");
+
+#ifdef LED_USE_JSON
+ std::string configFile{};
+ app.add_option("-c,--config", configFile, "Path to JSON config");
+#endif
+
+ CLI11_PARSE(app, argc, argv);
+
// Get a default event loop
auto event = sdeventplus::Event::get_default();
@@ -28,7 +38,7 @@
auto& bus = phosphor::led::utils::DBusHandler::getBus();
#ifdef LED_USE_JSON
- auto systemLedMap = getSystemLedMap();
+ auto systemLedMap = getSystemLedMap(configFile);
#endif
/** @brief Group manager object */