control: Replace Argument class with CLI11
Phosphor-fan already depends on cli11, delete Argument class and use
cli11 instead.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I4f4283f2d1c9a096a921814156ba81fea72eab34
diff --git a/control/main.cpp b/control/main.cpp
index 3596b14..e28e947 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -16,8 +16,9 @@
#include "config.h"
#ifndef CONTROL_USE_JSON
-#include "argument.hpp"
#include "manager.hpp"
+
+#include <CLI/CLI.hpp>
#else
#include "../utils/flight_recorder.hpp"
#include "json/manager.hpp"
@@ -53,28 +54,32 @@
auto event = phosphor::fan::util::SDEventPlus::getEvent();
#ifndef CONTROL_USE_JSON
- phosphor::fan::util::ArgumentParser args(argc, argv);
- if (argc != 2)
+ CLI::App app{"Phosphor Fan Control"};
+
+ bool init = false;
+ bool control = false;
+ app.add_flag("-i,--init", init, "Sets fans to full speed, delays, exits");
+ app.add_flag("-c,--control", control, "Start fan control algorithm");
+ app.require_option();
+
+ try
{
- args.usage(argv);
- return 1;
+ app.parse(argc, argv);
+ }
+ catch (const CLI::Error& e)
+ {
+ return app.exit(e);
}
Mode mode;
-
- if (args["init"] == "true")
+ if (init)
{
mode = Mode::init;
}
- else if (args["control"] == "true")
+ else if (control)
{
mode = Mode::control;
}
- else
- {
- args.usage(argv);
- return 1;
- }
#endif
// Attach the event object to the bus object so we can