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: