metaforce/hecl/driver/ToolHelp.hpp

95 lines
3.4 KiB
C++
Raw Normal View History

2015-06-10 02:40:03 +00:00
#ifndef CTOOL_HELP
#define CTOOL_HELP
#include "ToolBase.hpp"
2017-12-29 07:56:31 +00:00
#include <cstdio>
2015-06-10 02:40:03 +00:00
#include <functional>
class ToolHelp final : public ToolBase
{
public:
ToolHelp(const ToolPassInfo& info)
: ToolBase(info)
{
if (m_info.args.empty())
2015-07-26 02:52:02 +00:00
{
2016-03-04 23:02:44 +00:00
LogModule.report(logvisor::Error, "help requires a tool name argument");
2015-07-26 02:52:02 +00:00
return;
}
m_good = true;
2015-06-10 02:40:03 +00:00
}
~ToolHelp()
{
}
static void Help(HelpOutput& help)
{
2015-07-22 19:14:50 +00:00
help.printBold(
2015-07-26 02:52:02 +00:00
_S(" ___________ \n")
_S(" ,.-'\"...........``~., \n")
_S(" ,.-\".......................\"-., \n")
_S(" ,/..................................\":, \n")
_S(" .,?........................................, \n")
_S(" /...........................................,}\n")
_S(" ./........................................,:`^`..}\n")
_S(" ./.......................................,:\"...../\n")
_S(" ?.....__..................................:`...../\n")
_S(" /__.(...\"~-,_...........................,:`....../\n")
_S(" /(_....\"~,_....\"~,_.....................,:`...._/ \n")
_S(" {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n")
_S(" ((...*~_......\"=-._...\";,,./`........../\"..../ \n")
_S(" ,,,___.`~,......\"~.,....................`......}....../ \n")
2015-07-22 19:14:50 +00:00
_S("............(....`=-,,...`.........................(...;_,,-\" \n")
_S("............/.`~,......`-.................................../ \n")
_S(".............`~.*-,.....................................|,./...,__ \n")
_S(",,_..........}.>-._...................................|.......`=~-, \n")
_S(".....`=~-,__......`,................................. \n")
_S("...................`=~-,,.,........................... \n")
_S(".........................`:,,..........................`\n")
_S("...........................`=-,...............,%%`>--==`` \n")
_S(".................................._.........._,-%%...` \n")
_S("...................................,\n"));
2015-06-10 02:40:03 +00:00
}
2016-03-04 23:02:44 +00:00
static void ShowHelp(const hecl::SystemString& toolName)
2015-06-10 02:40:03 +00:00
{
/* Select tool's help-text streamer */
HelpOutput::HelpFunc helpFunc = NULL;
if (toolName == _S("init"))
helpFunc = ToolInit::Help;
else if (toolName == _S("spec"))
helpFunc = ToolSpec::Help;
2015-06-12 09:08:49 +00:00
else if (toolName == _S("extract"))
helpFunc = ToolExtract::Help;
2015-06-10 02:40:03 +00:00
else if (toolName == _S("cook"))
helpFunc = ToolCook::Help;
else if (toolName == _S("package") || toolName == _S("pack"))
helpFunc = ToolPackage::Help;
else if (toolName == _S("help"))
helpFunc = ToolHelp::Help;
else
{
2016-03-04 23:02:44 +00:00
LogModule.report(logvisor::Error, _S("unrecognized tool '%s' - can't help"), toolName.c_str());
2015-06-10 02:40:03 +00:00
return;
}
HelpOutput ho(helpFunc);
ho.go();
}
2016-03-04 23:02:44 +00:00
hecl::SystemString toolName() const {return _S("help");}
2015-06-10 02:40:03 +00:00
int run()
{
ShowHelp(m_info.args.front());
2015-06-10 02:40:03 +00:00
return 0;
}
};
#endif // CTOOL_HELP