summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-18 16:45:18 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-18 16:48:08 +0200
commitfaa8fc156ed8314db23a2d1612975ee745a50ade (patch)
treeb9c95d361d15de01e3708d3ca2a9604b915cef6d /src
parent6f8242d1a2f4c3eaeb856bcc33535a3faf6cf071 (diff)
downloadjustbuild-faa8fc156ed8314db23a2d1612975ee745a50ade.tar.gz
just-mr: Fix wrong exit code for --help call
Due to the specifics of how CLI11 library handles the --help argument and the fact that just-mr uses its own set of exit codes, we were correctly printing the help text, but falsely returning a non-zero exit code as result. This is now fixed.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/just_mr/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 871b86aa..51fb92f2 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -133,8 +133,11 @@ void SetupSetupCommandArguments(
try {
app.parse(argc, argv);
} catch (CLI::Error& e) {
- [[maybe_unused]] auto err = app.exit(e);
- std::exit(kExitClargsError);
+ // CLI11 throws for things like --help calls for them to be handled
+ // separately by parse callers. In this case it nevertheless sets the
+ // error code to 0 (success).
+ auto const err = app.exit(e);
+ std::exit(err == 0 ? kExitSuccess : kExitClargsError);
} catch (std::exception const& ex) {
Logger::Log(LogLevel::Error, "Command line parse error: {}", ex.what());
std::exit(kExitClargsError);