2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 22:27:43 +00:00

Implement hecl package

This commit is contained in:
Jack Andersen
2017-10-24 21:46:32 -10:00
parent a5b7a7b96c
commit b7208bfc5f
14 changed files with 374 additions and 198 deletions

View File

@@ -9,6 +9,7 @@
#ifndef _WIN32
#include <unistd.h>
#include <termios.h>
#endif
#include "hecl/Database.hpp"
@@ -29,23 +30,6 @@ struct ToolPassInfo
bool yes = false;
};
class ToolBase
{
protected:
const ToolPassInfo& m_info;
bool m_good = false;
public:
ToolBase(const ToolPassInfo& info)
: m_info(info)
{
hecl::VerbosityLevel = info.verbosityLevel;
}
virtual ~ToolBase() {}
virtual hecl::SystemString toolName() const=0;
virtual int run()=0;
inline operator bool() const {return m_good;}
};
#define RED "\033[0;31m"
#define GREEN "\033[0;32m"
#define YELLOW "\033[0;33m"
@@ -62,6 +46,58 @@ public:
extern bool XTERM_COLOR;
class ToolBase
{
protected:
const ToolPassInfo& m_info;
bool m_good = false;
bool continuePrompt()
{
if (!m_info.yes)
{
if (XTERM_COLOR)
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
else
hecl::Printf(_S("\nContinue? (Y/n) "));
int ch;
#ifndef _WIN32
struct termios tioOld, tioNew;
tcgetattr(0, &tioOld);
tioNew = tioOld;
tioNew.c_lflag &= ~ICANON;
tcsetattr(0, TCSANOW, &tioNew);
while ((ch = getchar()))
#else
while ((ch = getch()))
#endif
{
if (ch == 'n' || ch == 'N')
return false;
if (ch == 'y' || ch == 'Y' || ch == '\r' || ch == '\n')
break;
}
#ifndef _WIN32
tcsetattr(0, TCSANOW, &tioOld);
#endif
}
hecl::Printf(_S("\n"));
return true;
}
public:
ToolBase(const ToolPassInfo& info)
: m_info(info)
{
hecl::VerbosityLevel = info.verbosityLevel;
}
virtual ~ToolBase() {}
virtual hecl::SystemString toolName() const=0;
virtual int run()=0;
inline operator bool() const {return m_good;}
};
class HelpOutput
{
public: