添加默认配置生成功能。
This commit is contained in:
@@ -84,8 +84,9 @@ public:
|
||||
// 解析命令行参数
|
||||
bool parseArguments(int argc, char** argv)
|
||||
{
|
||||
auto msg = fmt::format("fileUpdater - 文件更新工具 \n\n {} on {} at {} {}", VERSION_GIT_COMMIT, VERSION_GIT_BRANCH,
|
||||
__DATE__, __TIME__);
|
||||
auto notice = "使用特殊参数 default 可生成一个默认配置文件模板。";
|
||||
auto msg = fmt::format("fileUpdater - 文件更新工具 \n\n {} on {} at {} {}\n{}", VERSION_GIT_COMMIT, VERSION_GIT_BRANCH,
|
||||
__DATE__, __TIME__, notice);
|
||||
CLI::App app{msg};
|
||||
argv = app.ensure_utf8(argv);
|
||||
|
||||
@@ -479,6 +480,28 @@ int main(int argc, char** argv)
|
||||
zoostCommon::SetOutputU8();
|
||||
zoostCommon::SetStdLibrayU8();
|
||||
|
||||
if (argc > 1) {
|
||||
std::string specialStr = argv[1];
|
||||
if (specialStr == "default") {
|
||||
std::string defaultContent =
|
||||
R"(<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AutoUpdate>
|
||||
<!-- 文件映射配置 -->
|
||||
<FileMapping m="a.txt" n="c/d/a.txt" type="file" ext=""/>
|
||||
<FileMapping m="" n="mm" type="dir" ext="txt|xml"/>
|
||||
</AutoUpdate>)";
|
||||
std::ifstream ifs("fileUpdater.xml");
|
||||
if (!ifs) {
|
||||
std::ofstream ofs("fileUpdater.xml");
|
||||
ofs << defaultContent;
|
||||
ofs.close();
|
||||
}
|
||||
ifs.close();
|
||||
boost::nowide::cout << "已生成默认配置文件: fileUpdater.xml" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdateTool tool;
|
||||
|
||||
if (tool.parseArguments(argc, argv)) {
|
||||
|
||||
Reference in New Issue
Block a user