-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Allow restricting search to crates with binaries for CLI completion purposes #11052
Comments
Thank you for the suggestion. I am a fish user as well ❤️ 🐟
|
It sounds like you are parsing the output of Another potential route is the proposed command for the index. The index doesn't have binary information but it would be useful for missing plugin error messages |
@weihanglo Thanks for being a fish user! The latest fish release has some dynamic completions in place for With regards to what you shared, IMHO it would be extremely unfortunate if whatever method of searching for crates with binaries confounds installable top-level binaries with installable tests or examples as the latter aren't the semantics of what we'd want to constrain the search to (in terms of making sure the completions for @epage I'm aware that the cargo search output isn't intended to be a fixed, machine-readable format. Unfortunately it's a common hazard writing completions for commands and the majority of CLI utilities do not expose a separate output format for machine ingestion. We are always updating the completions as the output of commands changes over time, either updating the regex patterns to apply across different versions of the output, abandoning old output formats, or gating parsing on the output of the tool version. We don't in any way mean for our completions to ever hinder upstream changes to the output format or even have developers think twice about changing something that some project might be parsing for its reasons, even if it means more work for our team - that's just the nature of the job 🤷 This is a completely separate topic but I figure here is as good of a place as any to bring it up rather than filing a new issue - is there any chance of being able to a) restrict searches to crate names (just like The issue is that As an example, executing The problem is that for a query like this, |
@mqudsi a more sustainable route might be to help towards clap-rs/clap#3166 followed by clap-rs/clap#1232. Clap's currently completion support isn't powerful enough for cargo but I'm hopeful that resolving those issues will make it so. This will then mean that cargo can provide the dynamic completion support itself along with every single command using clap. |
Problem
I'm a fish-shell developer, and we have "smarter"
cargo
completions in addition to those that were previously generated byclap
that generate dynamic completions based off the current environment instead of just what's statically baked into the binary via clap (e.g. autocompleting the names of available examples, tests, etc).I recently added support for autocompleting
cargo install ...
andcargo add ...
by getting crates matching the entered prefix viacargo search
but I was wondering if it would be trivial forcargo
to support acargo search --binary-only
orcargo search --installable
or whatever (even as a hidden/undocumented flag that could change or be removed in the future so it's not a binding commitment) that would restrict the search results to those that contain a binary.Proposed Solution
I'm not sure if this is technically possible - I would only ask for this feature if such information is readily available from the crate index without introspecting the project itself or doing anything similarly onerous/heavy. Currently we just list all crates and complete both
cargo install
andcargo add
the same way, but with this information we could further restrict completions forcargo install
to those that are actually installable.Notes
If it's not possible it's not a big deal - the only purpose here is to generate more relevant completions since cargo just does a loose string search on the provided keyword and we would be able to generate more applicable results if we could restrict what it returns (e.g. the 10 results
cargo search
provides are all installable and therefore potential candidates whereascargo search
for certain keywords or partial keywords may return 10 results none of which are installable and therefore none of which are - in the moment - relevant).The text was updated successfully, but these errors were encountered: