diff options
| author | Patrick Venture <venture@google.com> | 2019-03-11 09:11:55 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-03-11 09:27:39 -0700 |
| commit | b5cc37cebec74f0bd2a8d378d5f911fc4fa3439e (patch) | |
| tree | 8bec45837654acfe7df5192c3c0c659616e59d79 /main.cpp | |
| parent | 6d31049a4eb38f7b86874e9286c771ae0dd5f14d (diff) | |
| download | phosphor-pid-control-b5cc37cebec74f0bd2a8d378d5f911fc4fa3439e.tar.gz phosphor-pid-control-b5cc37cebec74f0bd2a8d378d5f911fc4fa3439e.zip | |
swap out getopts for cli11
Swap out getopt for cli11 for parsing parameters.
Change-Id: If6845c359dafc28b545925faa4701d401c7b8dd2
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 49 |
1 files changed, 15 insertions, 34 deletions
@@ -30,8 +30,7 @@ #include "threads/busthread.hpp" #include "util.hpp" -#include <getopt.h> - +#include <CLI/CLI.hpp> #include <chrono> #include <iostream> #include <map> @@ -60,39 +59,21 @@ int main(int argc, char* argv[]) { int rc = 0; std::string configPath = ""; + tuningLoggingPath = ""; - while (1) - { - // clang-format off - static struct option long_options[] = { - {"conf", required_argument, 0, 'c'}, - {"tuning", required_argument, 0, 't'}, - {0, 0, 0, 0} - }; - // clang-format on - - int option_index = 0; - int c = getopt_long(argc, argv, "t:c:", long_options, &option_index); - - if (c == -1) - { - break; - } - - switch (c) - { - case 'c': - configPath = std::string{optarg}; - break; - case 't': - tuningLoggingEnabled = true; - tuningLoggingPath = std::string{optarg}; - break; - default: - /* skip garbage. */ - continue; - } - } + CLI::App app{"OpenBMC Fan Control Daemon"}; + + app.add_option("-c,--conf", configPath, + "Optional parameter to specify configuration at run-time") + ->check(CLI::ExistingFile); + app.add_option("-t,--tuning", tuningLoggingPath, + "Optional parameter to specify tuning logging path, and " + "enable tuning") + ->check(CLI::ExistingFile); + + CLI11_PARSE(app, argc, argv); + + tuningLoggingEnabled = (tuningLoggingPath.length() > 0); auto modeControlBus = sdbusplus::bus::new_system(); static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl"; |

