Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dnf5/commands/download/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void DownloadCommand::set_argument_parser() {
cmd.register_named_arg(resolve);
cmd.register_named_arg(alldeps);
create_destdir_option(*this);
auto skip_unavailable = std::make_unique<SkipUnavailableOption>(*this);
cmd.register_named_arg(srpm);
cmd.register_named_arg(url);
cmd.register_named_arg(urlprotocol);
Expand Down Expand Up @@ -212,6 +213,14 @@ void DownloadCommand::run() {
pkg_query.filter_arch(std::vector<std::string>(arch_option.begin(), arch_option.end()));
}

if (!pkg_query.size() && !ctx.get_base().get_config().get_skip_unavailable_option().get_value()) {
// User tried `dnf5 download non-sense` or `dnf download non-sense-wildcard*`
throw libdnf5::cli::CommandExitError(
1,
M_("No package \"{}\" available; You might want to use --skip-unavailable option."),
option->get_value());
}

for (const auto & pkg : pkg_query) {
download_pkgs.insert(create_nevra_pkg_pair(pkg));

Expand Down
3 changes: 3 additions & 0 deletions doc/commands/download.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Options
``--destdir=<path>``
| Set directory used for downloading packages to. Default location is to the current working directory.

``--skip-unavailable``
| Allow skipping packages that are not available in repositories. All available packages will be downloaded.

``--srpm``
| Download the source rpm. Enables source repositories of all enabled binary repositories.

Expand Down