Merge pull request #7 from lioncash/override

driver: Minor general cleanup
This commit is contained in:
Phillip Stephens 2019-08-19 23:02:46 -07:00 committed by GitHub
commit 5659c46170
8 changed files with 33 additions and 33 deletions

View File

@ -88,7 +88,7 @@ protected:
} }
public: public:
ToolBase(const ToolPassInfo& info) : m_info(info) { explicit ToolBase(const ToolPassInfo& info) : m_info(info) {
hecl::VerbosityLevel = info.verbosityLevel; hecl::VerbosityLevel = info.verbosityLevel;
hecl::GuiMode = info.gui; hecl::GuiMode = info.gui;
} }
@ -96,15 +96,15 @@ public:
virtual hecl::SystemString toolName() const = 0; virtual hecl::SystemString toolName() const = 0;
virtual int run() = 0; virtual int run() = 0;
virtual void cancel() {} virtual void cancel() {}
inline operator bool() const { return m_good; } explicit operator bool() const { return m_good; }
}; };
class HelpOutput { class HelpOutput {
public: public:
typedef void (*HelpFunc)(HelpOutput&); using HelpFunc = void (*)(HelpOutput&);
private: private:
FILE* m_sout; FILE* m_sout = nullptr;
HelpFunc m_helpFunc; HelpFunc m_helpFunc;
int m_lineWidth; int m_lineWidth;
hecl::SystemString m_wrapBuffer; hecl::SystemString m_wrapBuffer;
@ -156,8 +156,8 @@ private:
} }
public: public:
HelpOutput(HelpFunc helpFunc) explicit HelpOutput(HelpFunc helpFunc)
: m_sout(NULL), m_helpFunc(helpFunc), m_lineWidth(hecl::GuiMode ? 120 : hecl::ConsoleWidth()) {} : m_helpFunc(helpFunc), m_lineWidth(hecl::GuiMode ? 120 : hecl::ConsoleWidth()) {}
void go() { void go() {
#if _WIN32 #if _WIN32

View File

@ -13,7 +13,7 @@ class ToolCook final : public ToolBase {
bool m_fast = false; bool m_fast = false;
public: public:
ToolCook(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) { explicit ToolCook(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) {
/* Check for recursive flag */ /* Check for recursive flag */
for (hecl::SystemChar arg : info.flags) for (hecl::SystemChar arg : info.flags)
if (arg == _SYS_STR('r')) if (arg == _SYS_STR('r'))
@ -145,9 +145,9 @@ public:
} }
} }
hecl::SystemString toolName() const { return _SYS_STR("cook"); } hecl::SystemString toolName() const override { return _SYS_STR("cook"); }
int run() { int run() override {
hecl::MultiProgressPrinter printer(true); hecl::MultiProgressPrinter printer(true);
hecl::ClientProcess cp(&printer); hecl::ClientProcess cp(&printer);
for (const hecl::ProjectPath& path : m_selectedItems) for (const hecl::ProjectPath& path : m_selectedItems)
@ -156,5 +156,5 @@ public:
return 0; return 0;
} }
void cancel() { m_useProj->interruptCook(); } void cancel() override { m_useProj->interruptCook(); }
}; };

View File

@ -27,7 +27,7 @@ class ToolExtract final : public ToolBase {
hecl::Database::Project* m_useProj = nullptr; hecl::Database::Project* m_useProj = nullptr;
public: public:
ToolExtract(const ToolPassInfo& info) : ToolBase(info) { explicit ToolExtract(const ToolPassInfo& info) : ToolBase(info) {
if (!m_info.args.size()) if (!m_info.args.size())
LogModule.report(logvisor::Fatal, fmt("hecl extract needs a source path as its first argument")); LogModule.report(logvisor::Fatal, fmt("hecl extract needs a source path as its first argument"));
@ -112,7 +112,7 @@ public:
help.endWrap(); help.endWrap();
} }
hecl::SystemString toolName() const { return _SYS_STR("extract"); } hecl::SystemString toolName() const override { return _SYS_STR("extract"); }
static void _recursivePrint(int level, hecl::Database::IDataSpec::ExtractReport& rep) { static void _recursivePrint(int level, hecl::Database::IDataSpec::ExtractReport& rep) {
for (int l = 0; l < level; ++l) for (int l = 0; l < level; ++l)
@ -129,7 +129,7 @@ public:
_recursivePrint(level + 1, child); _recursivePrint(level + 1, child);
} }
int run() { int run() override {
if (m_specPasses.empty()) { if (m_specPasses.empty()) {
if (XTERM_COLOR) if (XTERM_COLOR)
fmt::print(fmt(_SYS_STR("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n"))); fmt::print(fmt(_SYS_STR("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n")));

View File

@ -7,7 +7,7 @@
class ToolHelp final : public ToolBase { class ToolHelp final : public ToolBase {
public: public:
ToolHelp(const ToolPassInfo& info) : ToolBase(info) { explicit ToolHelp(const ToolPassInfo& info) : ToolBase(info) {
if (m_info.args.empty()) { if (m_info.args.empty()) {
LogModule.report(logvisor::Error, fmt("help requires a tool name argument")); LogModule.report(logvisor::Error, fmt("help requires a tool name argument"));
return; return;
@ -15,7 +15,7 @@ public:
m_good = true; m_good = true;
} }
~ToolHelp() {} ~ToolHelp() override = default;
static void Help(HelpOutput& help) { static void Help(HelpOutput& help) {
help.printBold( help.printBold(
@ -50,7 +50,7 @@ public:
static void ShowHelp(const hecl::SystemString& toolName) { static void ShowHelp(const hecl::SystemString& toolName) {
/* Select tool's help-text streamer */ /* Select tool's help-text streamer */
HelpOutput::HelpFunc helpFunc = NULL; HelpOutput::HelpFunc helpFunc = nullptr;
if (toolName == _SYS_STR("init")) if (toolName == _SYS_STR("init"))
helpFunc = ToolInit::Help; helpFunc = ToolInit::Help;
else if (toolName == _SYS_STR("spec")) else if (toolName == _SYS_STR("spec"))
@ -72,9 +72,9 @@ public:
ho.go(); ho.go();
} }
hecl::SystemString toolName() const { return _SYS_STR("help"); } hecl::SystemString toolName() const override { return _SYS_STR("help"); }
int run() { int run() override {
ShowHelp(m_info.args.front()); ShowHelp(m_info.args.front());
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@ class ToolImage final : public ToolBase {
hecl::Database::Project* m_useProj; hecl::Database::Project* m_useProj;
public: public:
ToolImage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) { explicit ToolImage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) {
if (!info.project) if (!info.project)
LogModule.report(logvisor::Fatal, fmt("hecl image must be ran within a project directory")); LogModule.report(logvisor::Fatal, fmt("hecl image must be ran within a project directory"));
@ -44,7 +44,7 @@ public:
"provided a path within a project")); "provided a path within a project"));
} }
~ToolImage() {} ~ToolImage() override = default;
static void Help(HelpOutput& help) { static void Help(HelpOutput& help) {
help.secHead(_SYS_STR("NAME")); help.secHead(_SYS_STR("NAME"));
@ -71,9 +71,9 @@ public:
help.endWrap(); help.endWrap();
} }
hecl::SystemString toolName() const { return _SYS_STR("image"); } hecl::SystemString toolName() const override { return _SYS_STR("image"); }
int run() { int run() override {
if (XTERM_COLOR) if (XTERM_COLOR)
fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n"))); fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n")));
else else

View File

@ -4,10 +4,10 @@
#include <cstdio> #include <cstdio>
class ToolInit final : public ToolBase { class ToolInit final : public ToolBase {
const hecl::SystemString* m_dir = NULL; const hecl::SystemString* m_dir = nullptr;
public: public:
ToolInit(const ToolPassInfo& info) : ToolBase(info) { explicit ToolInit(const ToolPassInfo& info) : ToolBase(info) {
hecl::Sstat theStat; hecl::Sstat theStat;
const hecl::SystemString* dir; const hecl::SystemString* dir;
if (info.args.size()) if (info.args.size())
@ -36,7 +36,7 @@ public:
m_dir = dir; m_dir = dir;
} }
int run() { int run() override {
if (!m_dir) if (!m_dir)
return 1; return 1;
size_t ErrorRef = logvisor::ErrorCount; size_t ErrorRef = logvisor::ErrorCount;
@ -73,5 +73,5 @@ public:
help.endWrap(); help.endWrap();
} }
hecl::SystemString toolName() const { return _SYS_STR("init"); } hecl::SystemString toolName() const override { return _SYS_STR("init"); }
}; };

View File

@ -59,7 +59,7 @@ class ToolPackage final : public ToolBase {
} }
public: public:
ToolPackage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) { explicit ToolPackage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) {
if (!info.project) if (!info.project)
LogModule.report(logvisor::Fatal, fmt("hecl package must be ran within a project directory")); LogModule.report(logvisor::Fatal, fmt("hecl package must be ran within a project directory"));
@ -156,9 +156,9 @@ public:
help.endWrap(); help.endWrap();
} }
hecl::SystemString toolName() const { return _SYS_STR("package"); } hecl::SystemString toolName() const override { return _SYS_STR("package"); }
int run() { int run() override {
if (XTERM_COLOR) if (XTERM_COLOR)
fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n"))); fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n")));
else else
@ -181,5 +181,5 @@ public:
return 0; return 0;
} }
void cancel() { m_useProj->interruptCook(); } void cancel() override { m_useProj->interruptCook(); }
}; };

View File

@ -8,7 +8,7 @@ class ToolSpec final : public ToolBase {
enum Mode { MLIST = 0, MENABLE, MDISABLE } mode = MLIST; enum Mode { MLIST = 0, MENABLE, MDISABLE } mode = MLIST;
public: public:
ToolSpec(const ToolPassInfo& info) : ToolBase(info) { explicit ToolSpec(const ToolPassInfo& info) : ToolBase(info) {
if (info.args.empty()) if (info.args.empty())
return; return;
@ -71,9 +71,9 @@ public:
help.endWrap(); help.endWrap();
} }
hecl::SystemString toolName() const { return _SYS_STR("spec"); } hecl::SystemString toolName() const override { return _SYS_STR("spec"); }
int run() { int run() override {
if (!m_info.project) { if (!m_info.project) {
for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) { for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) {
if (XTERM_COLOR) if (XTERM_COLOR)