From cda00bd756cccfa82d279ae1dc2fd421cd6fcb5c Mon Sep 17 00:00:00 2001 From: fangyunzhong Date: Mon, 28 Nov 2022 19:08:27 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20e0dcc70=20from=20https://gitee.com/fang?= =?UTF-8?q?-yunzhong/developtools=5Fglobal=5Fresource=5Ftool/pulls/67=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0-h=E5=8F=82=E6=95=B0=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B8=AE=E5=8A=A9=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fangyunzhong --- include/cmd_parser.h | 2 ++ src/cmd_parser.cpp | 12 +++++++++++- src/json_compiler.cpp | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/cmd_parser.h b/include/cmd_parser.h index 0702e66..ff6dcaf 100644 --- a/include/cmd_parser.h +++ b/include/cmd_parser.h @@ -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::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 diff --git a/src/cmd_parser.cpp b/src/cmd_parser.cpp index e7522f8..e4093d9 100644 --- a/src/cmd_parser.cpp +++ b/src/cmd_parser.cpp @@ -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::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) diff --git a/src/json_compiler.cpp b/src/json_compiler.cpp index 62cb683..f435bb6 100644 --- a/src/json_compiler.cpp +++ b/src/json_compiler.cpp @@ -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; }