增加-h参数,显示帮助菜单

Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
fangyunzhong
2022-11-28 19:08:27 +08:00
committed by fyz1019
parent 5630529451
commit cda00bd756
3 changed files with 14 additions and 2 deletions
+2
View File
@@ -75,6 +75,7 @@ private:
uint32_t AddAppend(const std::string& argValue);
uint32_t SetCombine();
uint32_t AddDependEntry(const std::string& argValue);
uint32_t ShowHelp() const;
bool IsAscii(const std::string& argValue) const;
static const struct option CMD_OPTS[];
@@ -128,6 +129,7 @@ void CmdParser<T>::ShowUseage()
std::cout << " -e start id mask, e.g 0x01000000, in [0x01000000, 0x06FFFFFF),[0x08000000, 0x41FFFFFF)\n";
std::cout << " -x resources folder path\n";
std::cout << " -z flag for incremental compilation\n";
std::cout << " -h Displays this help menu\n";
}
template<class T>
+11 -1
View File
@@ -39,9 +39,10 @@ const struct option PackageParser::CMD_OPTS[] = {
{ "append", required_argument, nullptr, 'x' },
{ "combine", required_argument, nullptr, 'z' },
{ "dependEntry", required_argument, nullptr, 'd' },
{ "help", no_argument, nullptr, 'h'},
};
const string PackageParser::CMD_PARAMS = "i:p:o:r:m:j:e:c:l:g:x:d:afvz";
const string PackageParser::CMD_PARAMS = "i:p:o:r:m:j:e:c:l:g:x:d:afhvz";
uint32_t PackageParser::Parse(int argc, char *argv[])
{
@@ -320,6 +321,14 @@ uint32_t PackageParser::AddDependEntry(const string& argValue)
return RESTOOL_SUCCESS;
}
uint32_t PackageParser::ShowHelp() const
{
auto &parser = CmdParser<PackageParser>::GetInstance();
parser.ShowUseage();
exit(RESTOOL_SUCCESS);
return RESTOOL_SUCCESS;
}
bool PackageParser::IsAscii(const string& argValue) const
{
#ifdef __WIN32
@@ -355,6 +364,7 @@ void PackageParser::InitCommand()
handles_.emplace('x', bind(&PackageParser::AddAppend, this, _1));
handles_.emplace('z', [this](const string &) -> uint32_t { return SetCombine(); });
handles_.emplace('d', bind(&PackageParser::AddDependEntry, this, _1));
handles_.emplace('h', [this](const string &) -> uint32_t { return ShowHelp(); });
}
uint32_t PackageParser::HandleProcess(int c, const string& argValue)
+1 -1
View File
@@ -302,7 +302,7 @@ bool JsonCompiler::CheckJsonStringValue(const Json::Value &valueNode, const Reso
ResType type = resourceItem.GetResType();
if (type == ResType::COLOR && !CheckColorValue(value.c_str())) {
string error = "invaild color value '" + value + \
"', only support refer '$color:xxx' or '#rgb','#argb','#rrggbb','aarrggbb'.";
"', only support refer '$color:xxx' or '#rgb','#argb','#rrggbb','#aarrggbb'.";
cerr << "Error: " << error << NEW_LINE_PATH << resourceItem.GetFilePath() << endl;
return false;
}