Skip to content
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

Bash completion: Always offer NEVRAs and NAMEs for packages #1983

Conversation

jrohel
Copy link
Contributor

@jrohel jrohel commented Jan 3, 2025

Closes: #1956

Originally, for packages, the NAME was offered in bash completion. In the case of multiple packages with the same NAME, there was an option to offer NEVRA instead of a NAME for those packages.

Now, bash completion always offers NEVRA for packages. There is an option to offer package NAME in addition to NEVRAs. This is useful, for example, when the user wants to install a package. Usually the user only wants to enter the package NAME and not the entire NEVRA. If multiple packages with the same NAME are available, the specific
package is then selected by the solver.

The DNF5 aplication now always offers both NEVRAs and NAMEs.

@evan-goode evan-goode self-assigned this Jan 3, 2025
@evan-goode
Copy link
Member

Nice, this works.

In the case of multiple packages with different nevras but the same name, there is an option to offer a name in addition to nevras for those packages.

I think I'd prefer also completing the name even if there is only one NEVRA available, i.e.

$ dnf5 --complete=2 dnf5 install hell
hello
hello-0:2.12.1-5.fc41.x86_64

mostly for the sake of consistency. It keeps the shell history a bit cleaner if the command is completed just as dnf5 install hello, and the user might intuitively expect a completion of just the package name and not the full NEVRA.

@jrohel jrohel force-pushed the always_nevra_in_bash_completion branch from c1b1fae to 2fcc09b Compare January 7, 2025 08:36
@jrohel jrohel changed the title For packages, always offer nevra in bash completion Bash completion: Always offer nevras and names for packages Jan 7, 2025
@jrohel jrohel changed the title Bash completion: Always offer nevras and names for packages Bash completion: Always offer NEVRAs and NAMEs for packages Jan 7, 2025
@jrohel jrohel force-pushed the always_nevra_in_bash_completion branch from 2fcc09b to ebefcc4 Compare January 7, 2025 08:53
jrohel added 2 commits January 7, 2025 09:53
Originally, for packages, the NAME was offered in bash completion.
In the case of multiple packages with the same NAME, there was an option
to offer NEVRA instead of the NAME for those packages.

Now, bash completion always offers NEVRA for packages.
There is an option to offer package NAMEs in addition to NEVRAs. This is
useful, for example, when the user wants to install a package. Usually
the user only wants to enter the package NAME and not the entire NEVRA.
If multiple packages with the same NAME are available, the specific
package is then selected by the solver.
For installed packages (for dnf5 commands reinstall, remove, repoquery,
swap) bash completion offered only NEVRAs. Now bash completion for dnf5
offers NAMEs in addition to NEVRAs in all cases.
@jrohel jrohel force-pushed the always_nevra_in_bash_completion branch from ebefcc4 to c17fa88 Compare January 7, 2025 08:53
@jrohel
Copy link
Contributor Author

jrohel commented Jan 7, 2025

I think I'd prefer also completing the name even if there is only one NEVRA available

OK. Sounds like a good idea. I've simplified the logic. Now NAMEs are always offered in addition to NEVRAs.

}
}

result_set.insert(package.get_full_nevra());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to skip the source rpm packages NEVRAS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to skip the source rpm packages NEVRAS?

Now, all matching packages from all allowed repositories are offered. Including source packages.
Fedora source packages are in their own repository, which is disabled by default. If the source package repository is enabled, source packages are offered.

Examples:

# dnf5 download iftop<TAB><TAB>
iftop                              iftop-0:1.0-0.34.pre4.fc41.x86_64  
# dnf5 --enable-repo=fedora-source download iftop<TAB><TAB>
iftop                              iftop-0:1.0-0.34.pre4.fc41.src     iftop-0:1.0-0.34.pre4.fc41.x86_64  

What is meant by the question? Do you want the source packages to not be offered? It is true that NEVRAs for source packages only make sense for certain commands - for example, download.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered it i copr repository, which contains both binary and source rpm. I was just thinking whether *.src packages are usable for the user. But it's really niche issue, as you said - most of the repositories do not contain source packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine that .src.rpms are suggested too, the user probably knows what they're doing if they select a specific NEVRA to install/remove/download.

Copy link
Member

@evan-goode evan-goode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good now.

@evan-goode evan-goode added this pull request to the merge queue Jan 8, 2025
Merged via the queue into rpm-software-management:main with commit 04016f4 Jan 8, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dnf5 bash completion does not include nevra information like dnf4
3 participants