metaforce/hecl/driver/ToolHelp.hpp

93 lines
3.6 KiB
C++
Raw Normal View History

2018-10-07 03:38:44 +00:00
#pragma once
2015-06-10 02:40:03 +00:00
#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(
2018-10-14 20:09:15 +00:00
_SYS_STR(" ___________ \n")
_SYS_STR(" ,.-'\"...........``~., \n")
_SYS_STR(" ,.-\".......................\"-., \n")
_SYS_STR(" ,/..................................\":, \n")
_SYS_STR(" .,?........................................, \n")
_SYS_STR(" /...........................................,}\n")
_SYS_STR(" ./........................................,:`^`..}\n")
_SYS_STR(" ./.......................................,:\"...../\n")
_SYS_STR(" ?.....__..................................:`...../\n")
_SYS_STR(" /__.(...\"~-,_...........................,:`....../\n")
_SYS_STR(" /(_....\"~,_....\"~,_.....................,:`...._/ \n")
_SYS_STR(" {.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n")
_SYS_STR(" ((...*~_......\"=-._...\";,,./`........../\"..../ \n")
_SYS_STR(" ,,,___.`~,......\"~.,....................`......}....../ \n")
_SYS_STR("............(....`=-,,...`.........................(...;_,,-\" \n")
_SYS_STR("............/.`~,......`-.................................../ \n")
_SYS_STR(".............`~.*-,.....................................|,./...,__ \n")
_SYS_STR(",,_..........}.>-._...................................|.......`=~-, \n")
_SYS_STR(".....`=~-,__......`,................................. \n")
_SYS_STR("...................`=~-,,.,........................... \n")
_SYS_STR(".........................`:,,..........................`\n")
_SYS_STR("...........................`=-,...............,%%`>--==`` \n")
_SYS_STR(".................................._.........._,-%%...` \n")
_SYS_STR("...................................,\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;
2018-10-14 20:09:15 +00:00
if (toolName == _SYS_STR("init"))
2015-06-10 02:40:03 +00:00
helpFunc = ToolInit::Help;
2018-10-14 20:09:15 +00:00
else if (toolName == _SYS_STR("spec"))
2015-06-10 02:40:03 +00:00
helpFunc = ToolSpec::Help;
2018-10-14 20:09:15 +00:00
else if (toolName == _SYS_STR("extract"))
2015-06-12 09:08:49 +00:00
helpFunc = ToolExtract::Help;
2018-10-14 20:09:15 +00:00
else if (toolName == _SYS_STR("cook"))
2015-06-10 02:40:03 +00:00
helpFunc = ToolCook::Help;
2018-10-14 20:09:15 +00:00
else if (toolName == _SYS_STR("package") || toolName == _SYS_STR("pack"))
2015-06-10 02:40:03 +00:00
helpFunc = ToolPackage::Help;
2018-10-14 20:09:15 +00:00
else if (toolName == _SYS_STR("help"))
2015-06-10 02:40:03 +00:00
helpFunc = ToolHelp::Help;
else
{
2018-10-14 20:09:15 +00:00
LogModule.report(logvisor::Error, _SYS_STR("unrecognized tool '%s' - can't help"), toolName.c_str());
2015-06-10 02:40:03 +00:00
return;
}
HelpOutput ho(helpFunc);
ho.go();
}
2018-10-14 20:09:15 +00:00
hecl::SystemString toolName() const {return _SYS_STR("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;
}
};