Tidying
This commit is contained in:
@@ -21,11 +21,11 @@ namespace Bloom
|
|||||||
|
|
||||||
if (!arguments.empty()) {
|
if (!arguments.empty()) {
|
||||||
auto& firstArg = arguments.front();
|
auto& firstArg = arguments.front();
|
||||||
const auto commandsToCallbackMapping = this->getCommandToHandlerMapping();
|
const auto commandHandlersByCommandName = this->getCommandHandlersByCommandName();
|
||||||
|
|
||||||
if (commandsToCallbackMapping.contains(firstArg)) {
|
if (commandHandlersByCommandName.contains(firstArg)) {
|
||||||
// User has passed an argument that maps to a command callback - invoke the callback and shutdown
|
// User has passed an argument that maps to a command callback - invoke the callback and shutdown
|
||||||
auto returnValue = commandsToCallbackMapping.at(firstArg)();
|
const auto returnValue = commandHandlersByCommandName.at(firstArg)();
|
||||||
|
|
||||||
this->shutdown();
|
this->shutdown();
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -85,7 +85,7 @@ namespace Bloom
|
|||||||
return geteuid() == 0;
|
return geteuid() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, std::function<int()>> Application::getCommandToHandlerMapping() {
|
std::map<std::string, std::function<int()>> Application::getCommandHandlersByCommandName() {
|
||||||
return std::map<std::string, std::function<int()>> {
|
return std::map<std::string, std::function<int()>> {
|
||||||
{
|
{
|
||||||
"--help",
|
"--help",
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ namespace Bloom
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Some CLI arguments are interpreted as commands and thus require specific handler methods to be called.
|
* Some CLI arguments are interpreted as commands and thus require specific handler methods to be called.
|
||||||
* This mapping maps command strings to the appropriate handler methods. The mapped handler method is invoked
|
* This mapping maps command names to the appropriate handler methods. The mapped handler method is invoked
|
||||||
* when the command is provided as an argument from the CLI.
|
* when the command name is provided as an argument from the CLI.
|
||||||
*
|
*
|
||||||
* See Application::run() for more on this.
|
* See Application::run() for more on this.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
std::map<std::string, std::function<int()>> getCommandToHandlerMapping();
|
std::map<std::string, std::function<int()>> getCommandHandlersByCommandName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kicks off the application.
|
* Kicks off the application.
|
||||||
|
|||||||
Reference in New Issue
Block a user