Files
2026-09-16 14:07:40 +08:00

86 lines
1.9 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <dl.h>
using namespace dl;
int main(int argc, char* argv[])
{
Engine::Init();
//TestScriptAll();
//TestScript(SCRIPT_TEST_VECTOR);
//TestScript(SCRIPT_TEST_EXPR);
//while (true)
//{
// log_msg("{:x}", UidGenerator::CreateUid());
//}
log_info("程序名: {}", CodeCvt::MultiByteToUtf8(argv[0]));
log_info("参数总数: {}", argc - 1);
for (int i = 1; i < argc; i++) {
log_info("参数{}: {}", i, CodeCvt::MultiByteToUtf8(argv[i]));
}
std::string lua_file;
#ifndef NDEBUG
//lua_file = "批量小写文件名.lua";
//lua_file = "批量清除图片透明色.lua";
//lua_file = "窗口示例.lua";
//lua_file = "批量缩放图片.lua";
//lua_file = "批量转换图片为PNG格式.lua";
//lua_file = "压缩文件(lz4.lua";
//lua_file = "解压文件(lz4.lua";
//lua_file = "批量计算文件哈希.lua";
//lua_file = "加密(AES-256.lua";
//lua_file = "解密(AES-256.lua";
#else
if(argc > 1)
lua_file = CodeCvt::MultiByteToUtf8(argv[1]);
#endif
//
if (lua_file.empty())
{
std::vector<std::string> all_lua;
File::SearchRule r;
r._vecFmt = { "lua" };
r._vecFilter = { "dl_api.lua" };
File::GetPathFileAll("./", all_lua, r);
if (!all_lua.empty())
{
std::string str = "《dl lua工具库》\n";
str+="你可以直接拖拽lua文件到exe上执行,也可以执行以下操作\n\n";
while (true)
{
str += "输入数字,选择要执行的lua脚本(0表示退出):\n";
for (size_t i = 0; i < all_lua.size(); ++i)
{
str += fmt::format("{}.{}\n", i + 1, all_lua[i]);
}
log_msg0(str);
str.clear();
int n = -1;
std::cin >> n;
if (n == 0)
break;
--n;
if (n < 0 || n >= all_lua.size())
std::cout << "输入无效,请重新输入:" << std::endl;
else
{
g_lua->DoFile(all_lua[n]);
}
}
}
}
else
{
g_lua->DoFile(lua_file);
}
Engine::Release();
return 0;
}