|
|
|
@ -29,25 +29,52 @@ std::function<void(std::shared_ptr<const ast_gen::ElementAccess>, int)> tnode_pr
|
|
|
|
|
tnode_print(c_n, intend + 1);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nsc --help
|
|
|
|
|
* 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.00" << 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<NovelParser>();
|
|
|
|
@ -126,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<printer::StoryLine> a, std::shared_ptr<printer::StoryLine> b)->bool{
|
|
|
|
|
std::sort(lines.begin(), lines.end(), [](std::shared_ptr<printer::StoryLine> a, std::shared_ptr<printer::StoryLine> b)->bool {
|
|
|
|
|
auto a_elm = std::dynamic_pointer_cast<const example_novel::StoryDefine>(a->accessPeers()->element());
|
|
|
|
|
auto b_elm = std::dynamic_pointer_cast<const example_novel::StoryDefine>(b->accessPeers()->element());
|
|
|
|
|
return a_elm->sort() < b_elm->sort();
|
|
|
|
|