metaforce/hecl/driver/CToolHelp.hpp

95 lines
3.6 KiB
C++
Raw Normal View History

2015-05-19 21:01:32 +00:00
#ifndef CTOOL_HELP
#define CTOOL_HELP
#include "CToolBase.hpp"
2015-05-20 05:22:32 +00:00
#include <stdio.h>
#include <stdexcept>
2015-05-26 04:42:20 +00:00
#include <functional>
2015-05-20 05:22:32 +00:00
class CToolHelp final : public CToolBase
{
2015-05-26 04:42:20 +00:00
public:
2015-05-20 05:22:32 +00:00
CToolHelp(const SToolPassInfo& info)
: CToolBase(info)
{
2015-05-20 05:45:19 +00:00
if (m_info.args.empty())
2015-05-20 05:22:32 +00:00
throw std::invalid_argument("help requires a tool name argument");
}
2015-05-20 05:22:32 +00:00
~CToolHelp()
{
}
2015-05-20 05:22:32 +00:00
2015-05-26 04:42:20 +00:00
static void Help(CHelpOutput& help)
2015-05-20 05:22:32 +00:00
{
2015-05-26 04:42:20 +00:00
help.printBold("................................___________ \n"
"...........................,.-'\"...........``~., \n"
"........................,.-\".......................\"-., \n"
"....................,/..................................\":, \n"
"..................,?........................................, \n"
"................/...........................................,}\n"
"............../........................................,:`^`..}\n"
"............./.......................................,:\"...../\n"
"............?.....__..................................:`...../\n"
".........../__.(...\"~-,_...........................,:`....../\n"
"........../(_....\"~,_....\"~,_.....................,:`...._/ \n"
"..........{.._$;_....\"=,_.....\"-,_......,.-~-,},.~\";/....} \n"
"...........((...*~_......\"=-._...\";,,./`........../\"..../ \n"
"...,,,___.`~,......\"~.,....................`......}....../ \n"
"............(....`=-,,...`.........................(...;_,,-\" \n"
"............/.`~,......`-.................................../ \n"
".............`~.*-,.....................................|,./...,__ \n"
",,_..........}.>-._...................................|.......`=~-, \n"
".....`=~-,__......`,................................. \n"
"...................`=~-,,.,........................... \n"
".........................`:,,..........................`\n"
"...........................`=-,...............,%%`>--==`` \n"
".................................._.........._,-%%...` \n"
"...................................,\n");
2015-05-20 05:22:32 +00:00
}
static void ToolHelp(const std::string& toolName)
{
2015-05-26 04:42:20 +00:00
/* Select tool's help-text streamer */
CHelpOutput::THelpFunc helpFunc = NULL;
2015-05-20 05:22:32 +00:00
if (toolName == "init")
2015-05-26 04:42:20 +00:00
helpFunc = CToolInit::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "add")
2015-05-26 04:42:20 +00:00
helpFunc = CToolAdd::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "remove" || toolName == "rm")
2015-05-26 04:42:20 +00:00
helpFunc = CToolRemove::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "group")
2015-05-26 04:42:20 +00:00
helpFunc = CToolGroup::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "cook")
2015-05-26 04:42:20 +00:00
helpFunc = CToolCook::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "clean")
2015-05-26 04:42:20 +00:00
helpFunc = CToolClean::Help;
else if (toolName == "package" || toolName == "pack")
helpFunc = CToolPackage::Help;
2015-05-20 05:22:32 +00:00
else if (toolName == "help")
2015-05-26 04:42:20 +00:00
helpFunc = CToolHelp::Help;
2015-05-20 05:22:32 +00:00
else
2015-05-26 04:42:20 +00:00
{
2015-05-20 05:22:32 +00:00
throw std::invalid_argument("unrecognized tool '" + toolName + "' - can't help");
2015-05-26 04:42:20 +00:00
return;
}
CHelpOutput ho(helpFunc);
ho.go();
2015-05-20 05:22:32 +00:00
}
std::string toolName() const {return "help";}
int run()
{
ToolHelp(m_info.args[0]);
return 0;
}
};
2015-05-19 21:01:32 +00:00
#endif // CTOOL_HELP