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

View File

@ -13,7 +13,7 @@ class ToolCook final : public ToolBase {
bool m_fast = false;
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 */
for (hecl::SystemChar arg : info.flags)
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::ClientProcess cp(&printer);
for (const hecl::ProjectPath& path : m_selectedItems)
@ -156,5 +156,5 @@ public:
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;
public:
ToolExtract(const ToolPassInfo& info) : ToolBase(info) {
explicit ToolExtract(const ToolPassInfo& info) : ToolBase(info) {
if (!m_info.args.size())
LogModule.report(logvisor::Fatal, fmt("hecl extract needs a source path as its first argument"));
@ -112,7 +112,7 @@ public:
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) {
for (int l = 0; l < level; ++l)
@ -129,7 +129,7 @@ public:
_recursivePrint(level + 1, child);
}
int run() {
int run() override {
if (m_specPasses.empty()) {
if (XTERM_COLOR)
fmt::print(fmt(_SYS_STR("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n")));

View File

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

View File

@ -15,7 +15,7 @@ class ToolImage final : public ToolBase {
hecl::Database::Project* m_useProj;
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)
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"));
}
~ToolImage() {}
~ToolImage() override = default;
static void Help(HelpOutput& help) {
help.secHead(_SYS_STR("NAME"));
@ -71,9 +71,9 @@ public:
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)
fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO IMAGE:" NORMAL "\n")));
else

View File

@ -4,10 +4,10 @@
#include <cstdio>
class ToolInit final : public ToolBase {
const hecl::SystemString* m_dir = NULL;
const hecl::SystemString* m_dir = nullptr;
public:
ToolInit(const ToolPassInfo& info) : ToolBase(info) {
explicit ToolInit(const ToolPassInfo& info) : ToolBase(info) {
hecl::Sstat theStat;
const hecl::SystemString* dir;
if (info.args.size())
@ -36,7 +36,7 @@ public:
m_dir = dir;
}
int run() {
int run() override {
if (!m_dir)
return 1;
size_t ErrorRef = logvisor::ErrorCount;
@ -73,5 +73,5 @@ public:
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:
ToolPackage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) {
explicit ToolPackage(const ToolPassInfo& info) : ToolBase(info), m_useProj(info.project) {
if (!info.project)
LogModule.report(logvisor::Fatal, fmt("hecl package must be ran within a project directory"));
@ -156,9 +156,9 @@ public:
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)
fmt::print(fmt(_SYS_STR("" GREEN BOLD "ABOUT TO PACKAGE:" NORMAL "\n")));
else
@ -181,5 +181,5 @@ public:
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;
public:
ToolSpec(const ToolPassInfo& info) : ToolBase(info) {
explicit ToolSpec(const ToolPassInfo& info) : ToolBase(info) {
if (info.args.empty())
return;
@ -71,9 +71,9 @@ public:
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) {
for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY) {
if (XTERM_COLOR)