Add modes to phosphor-fan-control

phosphor-fan-control can behave differently based
on its command line arguments

--init:  Set fans to full speed, delay for a
         configurable amount of time to allow fans to ramp up,
         start the fan control ready target, and then exit.

--control:  Start the control algorithm.  Never exits.
            Will be started as part of the fan control ready target.

Change-Id: I453daf8cc05a5c85a19c098e1cca64cac2ad9520
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/control/main.cpp b/control/main.cpp
index 08a7dc9..be5b59e 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -14,13 +14,46 @@
  * limitations under the License.
  */
 #include <sdbusplus/bus.hpp>
+#include "argument.hpp"
 #include "manager.hpp"
 
+using namespace phosphor::fan::control;
+
 int main(int argc, char* argv[])
 {
     auto bus = sdbusplus::bus::new_default();
+    phosphor::fan::util::ArgumentParser args(argc, argv);
 
-    phosphor::fan::control::Manager manager(bus);
+    if (argc != 2)
+    {
+        args.usage(argv);
+        exit(-1);
+    }
+
+    Manager::Mode mode;
+
+    if (args["init"] == "true")
+    {
+        mode = Manager::Mode::init;
+    }
+    else if (args["control"] == "true")
+    {
+        mode = Manager::Mode::control;
+    }
+    else
+    {
+        args.usage(argv);
+        exit(-1);
+    }
+
+    Manager manager(bus, mode);
+
+    //Init mode will just set fans to max and delay
+    if (mode == Manager::Mode::init)
+    {
+        manager.doInit();
+        return 0;
+    }
 
     while (true)
     {