Skip to content

Commit

Permalink
link SettingsAction directly with RouteType to clean Router::routeSet…
Browse files Browse the repository at this point in the history
…tings(), remove some old code
  • Loading branch information
rewrking committed Jun 13, 2022
1 parent 8576fe7 commit 1999d28
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 65 deletions.
20 changes: 0 additions & 20 deletions src/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ bool Application::handleRoute()
/*****************************************************************************/
void Application::initializeTerminal()
{
// Output::resetStdout();
// Output::resetStderr();

#if defined(CHALET_WIN32)
WindowsTerminal::initialize();
#endif
Expand All @@ -75,7 +72,6 @@ void Application::initializeTerminal()
Diagnostic::printErrors();
this->cleanup();
});
testSignalHandling();
#endif // _DEBUG
}

Expand Down Expand Up @@ -107,20 +103,4 @@ void Application::cleanup()
#endif
}

/*****************************************************************************/
void Application::testSignalHandling()
{
// int* test = nullptr;
// chalet_assert(test != nullptr, ""); // SIGABRT / abort
// int test2 = *test; // SIGSEGV / segmentation fault

// int a = 0;
// int test2 = 25 / a; // SIGFPE / arithmetic error

// LOG(test2);

// ::raise(SIGILL);
// ::raise(SIGTERM);
// ::raise(SIGABRT); // generic abort
}
}
2 changes: 0 additions & 2 deletions src/Core/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class Application
int onExit(const Status inStatus);
void cleanup();

void testSignalHandling();

Unique<CommandLineInputs> m_inputs;
};
}
Expand Down
21 changes: 1 addition & 20 deletions src/Router/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,27 +217,8 @@ bool Router::routeSettings()
{
const auto& route = m_inputs.route();

SettingsAction action = SettingsAction::Get;
switch (route.type())
{
case RouteType::SettingsSet:
action = SettingsAction::Set;
break;
case RouteType::SettingsGet:
action = SettingsAction::Get;
break;
case RouteType::SettingsUnset:
action = SettingsAction::Unset;
break;
case RouteType::SettingsGetKeys:
action = SettingsAction::QueryKeys;
break;
default:
return false;
}

SettingsManager settingsMgr(m_inputs);
if (!settingsMgr.run(action))
if (!settingsMgr.run(static_cast<SettingsAction>(route.type())))
return true;

return true;
Expand Down
12 changes: 7 additions & 5 deletions src/Settings/SettingsAction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
#ifndef CHALET_SETTINGS_ACTION_HPP
#define CHALET_SETTINGS_ACTION_HPP

#include "Router/RouteType.hpp"

namespace chalet
{
enum class SettingsAction : ushort
enum class SettingsAction : std::underlying_type_t<RouteType>
{
Get,
Set,
Unset,
QueryKeys,
Get = static_cast<std::underlying_type_t<RouteType>>(RouteType::SettingsGet),
Set = static_cast<std::underlying_type_t<RouteType>>(RouteType::SettingsSet),
Unset = static_cast<std::underlying_type_t<RouteType>>(RouteType::SettingsUnset),
QueryKeys = static_cast<std::underlying_type_t<RouteType>>(RouteType::SettingsGetKeys),
};
}

Expand Down
16 changes: 0 additions & 16 deletions src/Terminal/Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,6 @@ void Output::displayStyledSymbol(const Color inColor, const std::string_view inS
}
}

/*****************************************************************************/
void Output::resetStdout()
{
auto reset = getAnsiStyle(Color::Reset);
std::cout.write(reset.data(), reset.size());
std::cout.flush();
}

/*****************************************************************************/
void Output::resetStderr()
{
auto reset = getAnsiStyle(Color::Reset);
std::cerr.write(reset.data(), reset.size());
std::cerr.flush();
}

/*****************************************************************************/
void Output::lineBreak(const bool inForce)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Terminal/Output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ std::string getAnsiStyleForMakefile(const Color inColor);
std::string getAnsiStyleForceFormatting(const Color inColor, const Formatting inFormatting);

void displayStyledSymbol(const Color inColor, const std::string_view inSymbol, const std::string& inMessage);
void resetStdout();
void resetStderr();
void lineBreak(const bool inForce = false);
void lineBreakStderr();
void previousLine(const bool inForce = false);
Expand Down

0 comments on commit 1999d28

Please sign in to comment.