-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dnf5] Fix help in case argument parser detect error #450
Conversation
This PR is OK. According to the output, there is a bug in the CI tests. The "resolve" option is really missing in the last command. Last Command: dnf5 -y --installroot=/tmp/dnf_ci_installroot_ze5yse_k --releasever=29 --setopt=module_platform_id=platform:f29 --setopt=reposdir=/tmp/dnf_ci_installroot_ze5yse_k/etc/yum.repos.d --setopt=config_file_path=/tmp/dnf_ci_installroot_ze5yse_k/etc/dnf/dnf.conf --setopt=cachedir=/tmp/dnf_ci_installroot_ze5yse_k/var/cache/dnf download abcde --alldeps Last Command stderr: |
dnf5/main.cpp
Outdated
return static_cast<int>(libdnf::cli::ExitCode::SUCCESS); | ||
} | ||
} | ||
std::cerr << ex.what() << ". Add \"--help\" for more information about the arguments." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this literal with the gettext _( )
wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added. This reminded me to look at localization in dnf5 in general.
I think that's what the scenario tests - |
return static_cast<int>(libdnf::cli::ExitCode::ARGPARSER_ERROR); | ||
} catch (libdnf::cli::ArgumentParserError & ex) { | ||
std::cerr << ex.what() << std::endl; | ||
return static_cast<int>(libdnf::cli::ExitCode::ARGPARSER_ERROR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the catch
statements evokes that ArgumentParserError may actually never be raised in the corresponding try
statement. Does it mean that we should never ever throw
it in command->run()
etc.?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@praiskup I thought about it. There is at least one case where we throw an exception in command->configure (a problem with the download command). So I will modify the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m-blaha Good point. Thanks.
CI tests fails again:
|
- if the user wants help (--help/-h argument is present) -> print help and only help without errors and the application ends with the return code libdnf::cli::ExitCode::SUCCESS. - if user doesn't want help (--help/-h argument is not present) and argument parser detects missing/bad argument -> print an error message with a note about '--help' and application exits with return code libdnf::cli::ExitCode::ARGPARSER_ERROR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, LGTM.
Solves: #317
Requires modification of CI tests: rpm-software-management/ci-dnf-stack#1247