From 7ba4810002d684c8cd38599946d11b251b9072a1 Mon Sep 17 00:00:00 2001 From: yizhi <946185759@qq.com> Date: Mon, 24 Feb 2025 10:11:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=91=BD=E4=BB=A4=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=BC=BA=E5=B0=91=E6=89=A7=E8=A1=8C=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- src/commander.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0246f66..8125a98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,4 +6,4 @@ install(TARGETS commander DESTINATION lib) install(FILES "src/commander.h" DESTINATION include) add_executable(test src/main.cc) -target_link_libraries(test commander) \ No newline at end of file +target_link_libraries(test commander) diff --git a/src/commander.cc b/src/commander.cc index 8de7a24..43f5588 100644 --- a/src/commander.cc +++ b/src/commander.cc @@ -505,9 +505,9 @@ public: // 执行函数 auto fn = cmd->execute(); - if (fn) - return fn(CommandArgument(options, arguments)); - return 1; + if (!fn) + printUsage(cmd); + return fn(CommandArgument(options, arguments)); } private: