From fda7e465d8a8d93ebfd1a4aaefa02ea26b08b3c3 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 31 Oct 2024 15:01:52 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E4=BB=85?= =?UTF-8?q?=E7=94=9F=E6=88=90shell=E8=84=9A=E6=9C=AC=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd_parse.cpp | 9 +++++++-- install.cpp | 5 +++++ public.hpp | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd_parse.cpp b/cmd_parse.cpp index cac36c1..1ba8a3a 100644 --- a/cmd_parse.cpp +++ b/cmd_parse.cpp @@ -21,7 +21,9 @@ bool CCmdParse::cmdParse(int argc, char* argv[]) "安装目标目录")("file,f", cmd::value(), "二进制文件")( "ico,i", cmd::value(), "图标文件")( "category,c", cmd::value()->default_value("Utility"), - "分类名称,例如Utility。"); + "分类名称,例如Utility。")("only,o", + cmd::value()->default_value(false), + "仅生成shell启动脚本(mode=1时)"); cmd::variables_map vm; cmd::store(cmd::parse_command_line(argc, argv, desc), vm); @@ -35,6 +37,9 @@ bool CCmdParse::cmdParse(int argc, char* argv[]) if (vm.count("mode")) { result_.mode = vm["mode"].as(); } + if (vm.count("only")) { + result_.only_shell = vm["only"].as(); + } if (vm.count("dirs")) { result_.lib_dirs = vm["dirs"].as>(); } @@ -113,7 +118,7 @@ bool CCmdParse::Run() return pack.startPack(result_); } case 1: { - if (!check_file_dir(result_.ico, true)) { + if (!result_.only_shell && !check_file_dir(result_.ico, true)) { return false; } std::cout << "结果 ==========================================>\n"; diff --git a/install.cpp b/install.cpp index fe6f913..60911df 100644 --- a/install.cpp +++ b/install.cpp @@ -51,6 +51,11 @@ bool CInstallBinary::startInstall(const CmdResult& result) std::string cmd("chmod +x " + temp_shell.string()); std::cout << cmd << " Ret:" << std::system(cmd.c_str()) << std::endl; + if (result.only_shell) { + std::cout << "仅生成shell完成。" << std::endl; + return true; + } + if (!write_file(desktop_tempte, temp_desktop.string())) { return false; } diff --git a/public.hpp b/public.hpp index 6cf25fd..13d4930 100644 --- a/public.hpp +++ b/public.hpp @@ -13,6 +13,7 @@ struct CmdResult { bool valid{false}; int mode{-1}; bool help_{false}; + bool only_shell{false}; }; #endif \ No newline at end of file