From f0ed01bff6d4c457f7bd3f51cf60b99c9f378af1 Mon Sep 17 00:00:00 2001
From: codeboss <2422523675@qq.com>
Date: Wed, 5 Jun 2024 12:12:31 +0800
Subject: [PATCH] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=8F=82=E6=95=B0?=
=?UTF-8?q?=E6=94=B9=E8=BF=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
WsNovelParser/WsNovelParser.vcxproj.user | 2 +-
WsNovelParser/main.cpp | 38 +++++++++++++++++++-----
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/WsNovelParser/WsNovelParser.vcxproj.user b/WsNovelParser/WsNovelParser.vcxproj.user
index fc67585..835d788 100644
--- a/WsNovelParser/WsNovelParser.vcxproj.user
+++ b/WsNovelParser/WsNovelParser.vcxproj.user
@@ -3,7 +3,7 @@
$(SolutionDir)$(Platform)\$(Configuration)\
WindowsLocalDebugger
- -path "D:\手作小说\科学+修仙+创造世界"
+ --path "D:\手作小说\科学+修仙+创造世界"
2024-06-04T12:14:58.9515031Z
diff --git a/WsNovelParser/main.cpp b/WsNovelParser/main.cpp
index 93e3267..b3cfd81 100644
--- a/WsNovelParser/main.cpp
+++ b/WsNovelParser/main.cpp
@@ -34,25 +34,47 @@ std::function, int)> tnode_pr
* nsc [opts] --path path-to-dir
* opts:
* -p print-struct ṹ
+* -s service פ
*/
int main(int argc, char* argv[]) {
QCoreApplication a(argc, argv);
- if (argc != 3 || strcmp(argv[1], "-path")) {
+ QStringList args;
+ for (int idx = 0; idx < argc; idx++) {
+ args += QString::fromLocal8Bit(argv[idx]);
+ }
+
+ // ÷
+ if (args.contains(u8"--help")) {
std::cout << "nsc(WsNovelStoryCompiler߱)" << std::endl;
std::cout << "汾V1.0.0" << std::endl;
std::cout << "nsc -path path-to-dir" << std::endl;
exit(0);
}
- auto sdir = QDir::current();
- if (argc >= 3 && !strcmp(argv[1], "-path")) {
- auto tdir = QDir(QString::fromLocal8Bit(argv[2]));
- if (tdir.exists())
- sdir = tdir;
+ auto source_dir = QDir::current();
+ auto index = args.indexOf(u8"--path");
+ if (index < 0) {
+ std::cout << "ָ --path " << endl;
+ exit(1);
+ }
+ if (index + 1 >= args.size()) {
+ std::cout << "--path Ӧstoryļĸļ·" << std::endl;
+ exit(1);
+ }
+ else {
+ auto tdir = QDir(args[index+1]);
+ if (tdir.exists()) {
+ source_dir = tdir;
+ }
+ else {
+ std::cout << "storyļļ·Ч"<< std::endl;
+ exit(1);
+ }
}
- auto files = sdir.entryInfoList(QStringList() << "*.story");
+
+ auto files = source_dir.entryInfoList(QStringList() << "*.story");
if (files.size()) {
try {
auto parser = std::make_shared();
@@ -131,7 +153,7 @@ int main(int argc, char* argv[]) {
body.appendChild(dom_storyline);
auto lines = tool.storyline_defines.values();
- std::sort(lines.begin(), lines.end(), [](std::shared_ptr a, std::shared_ptr b)->bool{
+ std::sort(lines.begin(), lines.end(), [](std::shared_ptr a, std::shared_ptr b)->bool {
auto a_elm = std::dynamic_pointer_cast(a->accessPeers()->element());
auto b_elm = std::dynamic_pointer_cast(b->accessPeers()->element());
return a_elm->sort() < b_elm->sort();