This commit is contained in:
parent
48af8723ef
commit
37e3119934
|
@ -113,6 +113,17 @@ MatchMode::MatchMode(int mode_code, const QString& mode)
|
|||
*/
|
||||
|
||||
MatchMode& MatchMode::operator<<(std::shared_ptr<IArgvPack> unit) {
|
||||
if(unit->paramType() == ParamType::FloatParam){
|
||||
auto unit_in = std::dynamic_pointer_cast<__FloatArgvImpls>(unit);
|
||||
for (auto& u_exist : args_mode) {
|
||||
if (u_exist->paramType() == ParamType::FloatParam) {
|
||||
auto u_cast = std::dynamic_pointer_cast<__FloatArgvImpls>(u_exist);
|
||||
if (u_cast->bindKey() == unit_in->bindKey())
|
||||
throw new std::exception("重复设置选项");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
args_mode << unit;
|
||||
return *this;
|
||||
}
|
||||
|
@ -221,7 +232,7 @@ std::shared_ptr<IArgvPack> MatchMode::getUnitViaInitIndex(int pos) {
|
|||
return args_mode[pos];
|
||||
}
|
||||
|
||||
QString ArgsParser::helpDoc() const {
|
||||
QString ArgsParser::helperDoc() const {
|
||||
QString help_string;
|
||||
for (auto& mode : this->match_modes) {
|
||||
help_string += "Usage:" + mode->usageString() + "\n";
|
||||
|
|
|
@ -199,7 +199,7 @@ namespace args_parse {
|
|||
QList<std::shared_ptr<MatchMode>> match_modes;
|
||||
|
||||
public:
|
||||
QString helpDoc() const;
|
||||
QString helperDoc() const;
|
||||
|
||||
ArgsParser& operator<<(std::shared_ptr<MatchMode> mode);
|
||||
|
||||
|
|
|
@ -61,15 +61,25 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<TargetName>StoryPresent</TargetName>
|
||||
<IncludePath>$(SolutionDir)ArgsParser;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<IncludePath>$(SolutionDir)ArgsParser;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link />
|
||||
<Link>
|
||||
<AdditionalDependencies>ArgsParser.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link />
|
||||
<Link>
|
||||
<AdditionalDependencies>ArgsParser.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommandArguments>--graph --path D:\CustomNovel</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerCommandArguments>--help</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
|
|
@ -205,9 +205,7 @@ QList<std::shared_ptr<DAGOrderHelper>> DAGGraph::tidy_graph_nodes() {
|
|||
nodes_temp[node->bindPoint().name()] = std::make_shared<DAGOrderHelper>(node);
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<DAGOrderHelper>> temp_array;
|
||||
temp_array.append(nodes_temp.values());
|
||||
|
||||
QList<std::shared_ptr<DAGOrderHelper>> temp_array(nodes_temp.values());
|
||||
for (auto node : this->graph_inst.values()) {
|
||||
for (auto next : node->nextNodes()) {
|
||||
auto node_links = QList<std::shared_ptr<DAGOrderHelper>>{
|
||||
|
|
|
@ -3,13 +3,44 @@
|
|||
#include "xast_parse.h"
|
||||
#include "dag_present.h"
|
||||
#include "view_present.h"
|
||||
#include <argsparser.h>
|
||||
#include <QDebug>
|
||||
#include <qloggingcategory.h>
|
||||
#include <QMessageBox>
|
||||
#include <QTextEdit>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
|
||||
using namespace args_parse;
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
ArgsParser cmdrec;
|
||||
auto help_mode = std::make_shared<MatchMode>(0x000au, u8"打印帮助文档");
|
||||
cmdrec << help_mode;
|
||||
(*help_mode) << std::make_shared<IndexParam>(u8"StoryPresent", u8"程序名") << make_shared<FloatOption>(u8"help", u8"打印帮助文档");
|
||||
|
||||
auto rst = cmdrec.parse(argc, argv);
|
||||
QTextEdit msg;
|
||||
msg.setReadOnly(true);
|
||||
if (!rst) {
|
||||
msg.setWindowTitle(u8"参数输入错误");
|
||||
msg.setPlainText(cmdrec.helperDoc());
|
||||
msg.show();
|
||||
}
|
||||
else {
|
||||
switch (rst->modeCode()) {
|
||||
case 0x000au:
|
||||
msg.setWindowTitle(u8"帮助信息");
|
||||
msg.setPlainText(cmdrec.helperDoc());
|
||||
msg.show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
auto rst = entry_parser.parse(argc, argv);
|
||||
if (!rst) {
|
||||
qDebug().noquote() << u8"命令行参数错误";
|
||||
qDebug().noquote() << entry_parser.helpDoc();
|
||||
qDebug().noquote() << u8"命令行参数错误。";
|
||||
qDebug().noquote() << entry_parser.helperDoc();
|
||||
return 0;
|
||||
}
|
||||
if (rst->modeCode() == 0x000au) {
|
||||
qDebug().noquote() << entry_parser.helpDoc();
|
||||
qDebug().noquote() << entry_parser.helperDoc();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char* argv[]) {
|
|||
auto p_result = args_parser.parse(argc, argv);
|
||||
if (!p_result) {
|
||||
qDebug().noquote() << u8"命令行参数错误!";
|
||||
qDebug().noquote() << args_parser.helpDoc();
|
||||
qDebug().noquote() << args_parser.helperDoc();
|
||||
}
|
||||
else {
|
||||
switch (p_result->modeCode()) {
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char* argv[]) {
|
|||
}break;
|
||||
case 0xAu:
|
||||
default:
|
||||
qDebug().noquote() << args_parser.helpDoc();
|
||||
qDebug().noquote() << args_parser.helperDoc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue