Refactored for 'spec' tool

This commit is contained in:
Jack Andersen 2015-06-09 13:21:45 -10:00
parent 9de4d3fbe7
commit a4ab583a93
8 changed files with 45 additions and 30 deletions

View File

@ -6,4 +6,11 @@
#include "STRG.hpp" #include "STRG.hpp"
#include "TXTR.hpp" #include "TXTR.hpp"
const std::pair<std::string, std::string> DATA_SPECS[] =
{
{"hecl-little", "Targets little-endian pc apps using the HECL runtime"},
{"hecl-big", "Targets big-endian pc apps using the HECL runtime"},
{"hecl-revolution", "Targets Wii apps using the HECL runtime"},
{"hecl-cafe", "Targets Wii U apps using the HECL runtime"},
};

View File

@ -58,8 +58,8 @@ public:
CHelpOutput::THelpFunc helpFunc = NULL; CHelpOutput::THelpFunc helpFunc = NULL;
if (toolName == "init") if (toolName == "init")
helpFunc = CToolInit::Help; helpFunc = CToolInit::Help;
else if (toolName == "platform") else if (toolName == "spec")
helpFunc = CToolPlatform::Help; helpFunc = CToolSpec::Help;
else if (toolName == "add") else if (toolName == "add")
helpFunc = CToolAdd::Help; helpFunc = CToolAdd::Help;
else if (toolName == "remove" || toolName == "rm") else if (toolName == "remove" || toolName == "rm")

View File

@ -1,18 +1,18 @@
#ifndef CTOOL_PLATFORM #ifndef CTOOL_SPEC
#define CTOOL_PLATFORM #define CTOOL_SPEC
#include "CToolBase.hpp" #include "CToolBase.hpp"
#include <stdio.h> #include <stdio.h>
class CToolPlatform final : public CToolBase class CToolSpec final : public CToolBase
{ {
public: public:
CToolPlatform(const SToolPassInfo& info) CToolSpec(const SToolPassInfo& info)
: CToolBase(info) : CToolBase(info)
{ {
} }
~CToolPlatform() ~CToolSpec()
{ {
} }
@ -20,29 +20,29 @@ public:
{ {
help.secHead("NAME"); help.secHead("NAME");
help.beginWrap(); help.beginWrap();
help.wrap("hecl-platform - Configure platform target options\n"); help.wrap("hecl-spec - Configure target data options\n");
help.endWrap(); help.endWrap();
help.secHead("SYNOPSIS"); help.secHead("SYNOPSIS");
help.beginWrap(); help.beginWrap();
help.wrap("hecl platform [enable|disable] [<platname>...]\n"); help.wrap("hecl spec [enable|disable] [<specname>...]\n");
help.endWrap(); help.endWrap();
help.secHead("DESCRIPTION"); help.secHead("DESCRIPTION");
help.beginWrap(); help.beginWrap();
help.wrap("This command configures the HECL project with the user's preferred target platforms.\n\n" help.wrap("This command configures the HECL project with the user's preferred target DataSpecs.\n\n"
"Providing enable/disable argument will bulk-set the enable status of the provided platform" "Providing enable/disable argument will bulk-set the enable status of the provided spec(s)"
"list. If enable/disable is not provided, a list of supported platforms is printed.\n\n"); "list. If enable/disable is not provided, a list of supported DataSpecs is printed.\n\n");
help.endWrap(); help.endWrap();
help.secHead("OPTIONS"); help.secHead("OPTIONS");
help.optionHead("<platname>...", "platform name(s)"); help.optionHead("<specname>...", "DataSpec name(s)");
help.beginWrap(); help.beginWrap();
help.wrap("Specifies platform-names to enable/disable"); help.wrap("Specifies platform-names to enable/disable");
help.endWrap(); help.endWrap();
} }
std::string toolName() const {return "platform";} std::string toolName() const {return "spec";}
int run() int run()
{ {
@ -50,4 +50,4 @@ public:
} }
}; };
#endif // CTOOL_PLATFORM #endif // CTOOL_SPEC

View File

@ -33,5 +33,5 @@ HEADERS += \
CToolClean.hpp \ CToolClean.hpp \
CToolAdd.hpp \ CToolAdd.hpp \
CToolRemove.hpp \ CToolRemove.hpp \
CToolPlatform.hpp CToolSpec.hpp

View File

@ -9,7 +9,7 @@
#include "CToolBase.hpp" #include "CToolBase.hpp"
#include "CToolInit.hpp" #include "CToolInit.hpp"
#include "CToolPlatform.hpp" #include "CToolSpec.hpp"
#include "CToolAdd.hpp" #include "CToolAdd.hpp"
#include "CToolRemove.hpp" #include "CToolRemove.hpp"
#include "CToolGroup.hpp" #include "CToolGroup.hpp"

View File

@ -3,7 +3,7 @@
_hecl () _hecl ()
{ {
local word=${COMP_WORDS[COMP_CWORD]} local word=${COMP_WORDS[COMP_CWORD]}
local filecmds=(init platform add remove group cook clean package) local filecmds=(init spec add remove group cook clean package)
if [ $COMP_CWORD == 1 ] if [ $COMP_CWORD == 1 ]
then then
@ -15,7 +15,7 @@ _hecl ()
init|add|remove|group|cook|clean|package) init|add|remove|group|cook|clean|package)
COMPREPLY=($(compgen -f -- "${word}")) COMPREPLY=($(compgen -f -- "${word}"))
;; ;;
platform) spec)
COMPREPLY=($(compgen -W "enable disable" "${word}")) COMPREPLY=($(compgen -W "enable disable" "${word}"))
;; ;;
help) help)

View File

@ -207,24 +207,24 @@ public:
virtual bool removeGroup(const HECL::ProjectPath& path); virtual bool removeGroup(const HECL::ProjectPath& path);
/** /**
* @brief Return map populated with platforms targetable by this project interface * @brief Return map populated with dataspecs targetable by this project interface
* @return Platform map with name-string keys and enable-status values * @return Platform map with name-string keys and enable-status values
*/ */
virtual const std::map<const std::string, const bool>& listPlatforms(); virtual const std::map<const std::string, const bool>& listDataSpecs();
/** /**
* @brief Enable persistent user preference for particular platform string(s) * @brief Enable persistent user preference for particular spec string(s)
* @param platforms String(s) representing unique platform(s) from listPlatforms * @param specs String(s) representing unique spec(s) from listDataSpecs
* @return true on success * @return true on success
*/ */
virtual bool enablePlatforms(const std::vector<std::string>& platforms); virtual bool enableDataSpecs(const std::vector<std::string>& specs);
/** /**
* @brief Disable persistent user preference for particular platform string(s) * @brief Disable persistent user preference for particular spec string(s)
* @param platform String(s) representing unique platform(s) from listPlatforms * @param specs String(s) representing unique spec(s) from listDataSpecs
* @return true on success * @return true on success
*/ */
virtual bool disablePlatforms(const std::vector<std::string>& platforms); virtual bool disableDataSpecs(const std::vector<std::string>& specs);
/** /**
* @brief Begin cook process for specified directory * @brief Begin cook process for specified directory

View File

@ -9,6 +9,10 @@
namespace HECLDatabase namespace HECLDatabase
{ {
/**********************************************
* Project::ConfigFile
**********************************************/
static inline bool CheckNewLineAdvance(std::string::const_iterator& it) static inline bool CheckNewLineAdvance(std::string::const_iterator& it)
{ {
if (*it == '\n' || *it == '\0') if (*it == '\n' || *it == '\0')
@ -110,6 +114,10 @@ bool Project::ConfigFile::checkForLine(const std::string& refLine)
return false; return false;
} }
/**********************************************
* Project
**********************************************/
Project::Project(const std::string& rootPath) Project::Project(const std::string& rootPath)
: m_rootPath(rootPath) : m_rootPath(rootPath)
{ {
@ -153,15 +161,15 @@ bool Project::removeGroup(const HECL::ProjectPath& path)
{ {
} }
const std::map<const std::string, const bool>& Project::listPlatforms() const std::map<const std::string, const bool>& Project::listDataSpecs()
{ {
} }
bool Project::enablePlatforms(const std::vector<std::string>& platforms) bool Project::enableDataSpecs(const std::vector<std::string>& specs)
{ {
} }
bool Project::disablePlatforms(const std::vector<std::string>& platforms) bool Project::disableDataSpecs(const std::vector<std::string>& specs)
{ {
} }