Create a new Dbus interface for LED

A new Dbus API method is created in the phosphor-led-sysfs repository
under xyz.openbmc_project.Led.Sysfs.Internal interface name to add or
remove the LED, which will be coming from each udev LED event to
create the LED dbus path.

xyz.openbmc_project.Led.Sysfs.Internal interface
.AddLED                                method
.RemoveLED                             method

This Dbus API method is added to support the multihost physical
LEDs design.
https://gerrit.openbmc.org/c/openbmc/docs/+/55230

Also support a executable for LED DBUS API method

Added a new executable for LED DBUS API method to communicate
between udev and application.

Executable will call Dbus API method to pass LED name as argument from
udev, after the primary service started.

Tested : Tested the dbus method is invoked for each LED udev event
in Facebook YosemiteV2 platform.

Signed-off-by: Jayashree Dhanapal <jayashree-d@hcl.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I3fa6c3caa130b2b71ebc9fe8d69541c029f516ab
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/argument.hpp b/argument.hpp
new file mode 100644
index 0000000..42b1338
--- /dev/null
+++ b/argument.hpp
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <getopt.h>
+
+#include <map>
+#include <string>
+
+namespace phosphor
+{
+namespace led
+{
+/** @brief Class - Encapsulates parsing command line options and
+ *                 populating arguments
+ */
+class ArgumentParser
+{
+  public:
+    ArgumentParser() = delete;
+    ~ArgumentParser() = default;
+    ArgumentParser(const ArgumentParser&) = delete;
+    ArgumentParser& operator=(const ArgumentParser&) = delete;
+    ArgumentParser(ArgumentParser&&) = default;
+    ArgumentParser& operator=(ArgumentParser&&) = default;
+
+    /** @brief Constructs Argument object
+     *
+     *  @param argc - the main function's argc passed as is
+     *  @param argv - the main function's argv passed as is
+     *  @return Object constructed
+     */
+    // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
+    ArgumentParser(int argc, char* argv[]);
+
+    /** @brief Given a option, returns its argument(optarg) */
+    const std::string& operator[](const std::string& opt);
+
+    /** @brief Displays usage */
+    // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
+    static void usage(char* argv[]);
+
+  private:
+    /** @brief Option to argument mapping */
+    std::map<const std::string, std::string> arguments;
+
+    /** @brief Array of struct options as needed by getopt_long */
+    // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
+    static inline const option options[] = {
+        {"path", required_argument, nullptr, 'p'},
+        {"help", no_argument, nullptr, 'h'},
+        {nullptr, 0, nullptr, 0},
+    };
+
+    /** @brief optstring as needed by getopt_long */
+    static inline const char* const optionstr = "p:?h";
+};
+
+} // namespace led
+} // namespace phosphor