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

Tab completion: rye run x should yield completion to the called executable #213

Closed
whi-tw opened this issue May 24, 2023 · 11 comments
Closed
Labels
enhancement New feature or request

Comments

@whi-tw
Copy link

whi-tw commented May 24, 2023

Steps to Reproduce

  1. rye run pyt <tab>

  2. rye run -- pyt <tab>

Expected Result

I'd expect to see the completions of the called command

Actual Result

No completions, bell sounds

Version Info

rye 0.2.0
commit: 0.2.0 (d875838 2023-05-23)
platform: macos (aarch64)
self-python: cpython@3.10
symlink support: true

Stacktrace

No response

@whi-tw
Copy link
Author

whi-tw commented May 24, 2023

This has been achieved nicely in 99designs/aws-vault for bash,zsh and fish.

Their implementation uses a switch on -- - all completion after that sequence is handed off back to the shell's concept of _normal (ie. as if you triggered completion with an empty prompt line)

@mitsuhiko
Copy link
Collaborator

mitsuhiko commented May 24, 2023

I'm not sure exactly what the ask is here. You can already generate a completion script. Is the ask to automatically install these?

rye self completion -s zsh

@whi-tw
Copy link
Author

whi-tw commented May 24, 2023

No, sorry, not that.

The ask is that rye run -- py<tab> would return the same completion options as if you just typed py<tab> on the cli.

This would mean you could use tab completion for commands which are run using rye run, rather than them just being swallowed up as no-ops by _rye.

@mitsuhiko
Copy link
Collaborator

Not sure if it's possible to actually do this without generating out a really complex script. The issue is that the completion would actually depend on what's configured in the scripts or what can be found. It's not invoking directly a script on PATH.

@whi-tw
Copy link
Author

whi-tw commented May 24, 2023

I've written a number of CLI apps which do this, using the patterns in the scripts I linked here: #213 (comment) - do you not think those would work in the case of rye?

I'm not super au-fait with rust, but I might have a go and see if I can get something working

@mitsuhiko
Copy link
Collaborator

The issue here is not Rust, but that the command after rye run is not on the PATH. So how would the shell know what to expand?

@whi-tw
Copy link
Author

whi-tw commented May 24, 2023

oooh, valid point 🤦🏻‍♂️ I had my head in "general-task-runner" mode, not "we're running commands in a very specific environment" mode.

completely misread this:

The issue is that the completion would actually depend on what's configured in the scripts or what can be found

@whi-tw whi-tw closed this as completed May 24, 2023
@whi-tw whi-tw closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2023
@mitsuhiko
Copy link
Collaborator

I think if this ever gets fixed it might be possible to do something: clap-rs/clap#1232

@mitsuhiko mitsuhiko reopened this May 24, 2023
@mitsuhiko mitsuhiko added the enhancement New feature or request label May 24, 2023
@mitsuhiko
Copy link
Collaborator

Closing this for now as I do not believe work here will actually take place.

@abdulhaq-e
Copy link

I'm asking this here since it's related. I'm not a shell expert but here is what I know from observation; when shells can't provide completion then the suggestions are files/directories in the current working directory. For some reason, rye run pytest [tab] is not doing that.

In poetry and pdm and most tools I'm able to select a file or directory.

Usage: I usually run tests found in a specific directory and it would be nice if I can get completion working to make a selection quickly.

@hgaiser
Copy link

hgaiser commented May 23, 2024

I agree with @abdulhaq-e . At the moment rye seems to consume any tab event, but it would be nice to do rye run foo /path/to/<tab> and have it autocomplete whatever is in that directory. Should this be a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants