From c292df73c3e21d3e19652397c2c5c5c20dbe03f5 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Tue, 17 Oct 2023 18:36:55 +0000 Subject: [PATCH] Don't print missing positional argument error with --help --- dnf5/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dnf5/main.cpp b/dnf5/main.cpp index 61fe0fa28..7c471aea6 100644 --- a/dnf5/main.cpp +++ b/dnf5/main.cpp @@ -973,6 +973,11 @@ int main(int argc, char * argv[]) try { if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0) { arg_parser.get_selected_command()->help(); help_printed = true; + // Ignore the error and exit 0 if it's just a missing + // positional argument, e.g. `dnf5 install --help` + if (dynamic_cast(&ex)) { + return static_cast(libdnf5::cli::ExitCode::SUCCESS); + } break; } }