Skip to content

Commit

Permalink
Add --urlprotocol option to download command
Browse files Browse the repository at this point in the history
  • Loading branch information
derickdiaz committed Jan 25, 2024
1 parent 33fbf59 commit e36fb2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dnf5/commands/download/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void DownloadCommand::set_argument_parser() {

auto url = parser.add_new_named_arg("url");
url->set_long_name("url");
url->set_description("Print a url where the rpms can be downloaded instead of downloading");
url->set_description("Print a URL where the rpms can be downloaded instead of downloading");
url->set_const_value("true");
url->link_value(url_option);

Expand All @@ -92,7 +92,7 @@ void DownloadCommand::set_argument_parser() {
urlprotocol->set_long_name("urlprotocol");
urlprotocol->set_description("When running with --url, limit to specific protocols");
urlprotocol->set_has_value(true);
urlprotocol->set_arg_value_help("{http, https, ftp, file},...");
urlprotocol->set_arg_value_help("{http|https|ftp|file},...");
urlprotocol->set_parse_hook_func(
[this](
[[maybe_unused]] ArgumentParser::NamedArg * arg, [[maybe_unused]] const char * option, const char * value) {
Expand Down
6 changes: 3 additions & 3 deletions doc/commands/download.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Options
| Set directory used for downloading packages to. Default location is to the current working directory.
``--url``
| Prints the list of urls where the rpms can be downloaded instead of downloading.
| Prints the list of URLs where the rpms can be downloaded instead of downloading.
``--urlprotocol``
| To be used together with ``--url``, it filters out the urls to the specified url protocols: {http, https, ftp, file}
| To be used together with ``--url``. It filters out the URLs to the specified protocols: ``http``, ``https``, ``ftp``, or ``file``. This option can be used multiple times.


Expand All @@ -71,7 +71,7 @@ Examples
| Download the ``maven-compiler-plugin`` package to ``/tmp/my_packages`` directory.
``dnf5 download --url --urlprotocol http python``
| List the http url to download the python package
| List the http URL to download the python package

See Also
Expand Down
2 changes: 0 additions & 2 deletions libdnf5/rpm/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ std::vector<std::string> Package::get_remote_locations(const std::set<std::strin
auto repo_baseurls = get_repo()->get_config().get_baseurl_option().get_value();
for (const auto & baseurl : repo_baseurls) {
for (const auto & protocol : protocols) {
// Ensure the urls matches the protocol specified by concating the colon.
// i.e https: or http: not httpnextgen:
if (utils::string::starts_with(baseurl, protocol + ":")) {
auto path = lr_pathconcat(baseurl.c_str(), location.c_str(), NULL);
remote_locations.emplace_back(path);
Expand Down

0 comments on commit e36fb2f

Please sign in to comment.