Clean up CLI naming
Now that all applications run through one CLI, names like run() don't
make a lot of sense. Update names to match the new reality, make bmcweb
with no arguments launch the webserver once again.
Tested: bmcweb boots.
Change-Id: I011b57507872a9518a9c470b58779805504c7293
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/include/webserver_run.hpp b/include/webserver_run.hpp
index e083225..15a3a5a 100644
--- a/include/webserver_run.hpp
+++ b/include/webserver_run.hpp
@@ -2,4 +2,4 @@
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
-int run();
+int runWebserver();
diff --git a/src/webserver_cli.cpp b/src/webserver_cli.cpp
index 521a250..34c13e3 100644
--- a/src/webserver_cli.cpp
+++ b/src/webserver_cli.cpp
@@ -50,43 +50,7 @@
return help;
}
-static int loglevelMain(std::string& loglevel);
-
-int cliMain(int argc, char** argv) noexcept(false)
-{
- CLI::App app("BMCWeb CLI");
-
- cliLogLevel("INFO");
-
- std::string loglevel;
- app.require_subcommand(1);
-
- const CLI::Validator levelValidator =
- CLI::Validator(validateLogLevel, "valid level");
-
- CLI::App* sub = app.add_subcommand("loglevel", "Set bmcweb log level");
- sub->add_option("level", loglevel, helpMsg())
- ->required()
- ->check(levelValidator);
-
- CLI::App* daemon = app.add_subcommand("daemon", "Run webserver");
-
- CLI11_PARSE(app, argc, argv)
-
- if (daemon->parsed())
- {
- return run();
- }
-
- if (sub->parsed())
- {
- return loglevelMain(loglevel);
- }
-
- return 0;
-}
-
-static int loglevelMain(std::string& loglevel)
+static int setLogLevel(std::string& loglevel)
{
// Define sdbus interfaces:
std::string service = "xyz.openbmc_project.bmcweb";
@@ -119,3 +83,37 @@
return 0;
}
+
+int runCLI(int argc, char** argv) noexcept(false)
+{
+ CLI::App app("BMCWeb CLI");
+
+ cliLogLevel("INFO");
+
+ const CLI::Validator levelValidator =
+ CLI::Validator(validateLogLevel, "valid level");
+
+ CLI::App* loglevelsub =
+ app.add_subcommand("loglevel", "Set bmcweb log level");
+
+ std::string loglevel;
+ loglevelsub->add_option("level", loglevel, helpMsg())
+ ->required()
+ ->check(levelValidator);
+
+ CLI::App* daemon = app.add_subcommand("daemon", "Run webserver");
+
+ CLI11_PARSE(app, argc, argv)
+
+ if (loglevelsub->parsed())
+ {
+ return setLogLevel(loglevel);
+ }
+ if (daemon->parsed())
+ {
+ return runWebserver();
+ }
+ runWebserver();
+
+ return 0;
+}
diff --git a/src/webserver_cli.hpp b/src/webserver_cli.hpp
index 0fe47af..7b8d48d 100644
--- a/src/webserver_cli.hpp
+++ b/src/webserver_cli.hpp
@@ -1,4 +1,6 @@
+#pragma once
+
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
-int cliMain(int argc, char** argv) noexcept(false);
+int runCLI(int argc, char** argv) noexcept(false);
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index 159ec80..c6ac24e 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -5,5 +5,5 @@
int main(int argc, char** argv) noexcept(false)
{
- return cliMain(argc, argv);
+ return runCLI(argc, argv);
}
diff --git a/src/webserver_run.cpp b/src/webserver_run.cpp
index a717a8d..b7c014e 100644
--- a/src/webserver_run.cpp
+++ b/src/webserver_run.cpp
@@ -48,7 +48,7 @@
BMCWEB_LOG_INFO("Requested log-level change to: {}", logLevel);
}
-int run()
+int runWebserver()
{
boost::asio::io_context& io = getIoContext();
App app;