monitor: 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: I017ff2012f73d0025ea04f6fe1d5d86710e04645
diff --git a/monitor/main.cpp b/monitor/main.cpp
index fbdcd0d..8505c76 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -16,7 +16,7 @@
#include "config.h"
#ifndef MONITOR_USE_JSON
-#include "argument.hpp"
+#include <CLI/CLI.hpp>
#endif
#include "fan.hpp"
#ifdef MONITOR_USE_JSON
@@ -41,27 +41,31 @@
Mode mode = Mode::init;
#ifndef MONITOR_USE_JSON
- phosphor::fan::util::ArgumentParser args(argc, argv);
+ CLI::App app{"Phosphor Fan Monitor"};
- if (argc != 2)
+ bool init = false;
+ bool monitor = false;
+ app.add_flag("-i,--init", init, "Set fans to functional");
+ app.add_flag("-m,--monitor", monitor, "Start fan functional monitoring");
+ app.require_option();
+
+ try
{
- args.usage(argv);
- return 1;
+ app.parse(argc, argv);
+ }
+ catch (const CLI::Error& e)
+ {
+ return app.exit(e);
}
- if (args["init"] == "true")
+ if (init)
{
mode = Mode::init;
}
- else if (args["monitor"] == "true")
+ else if (monitor)
{
mode = Mode::monitor;
}
- else
- {
- args.usage(argv);
- return 1;
- }
#endif
// Attach the event object to the bus object so we can