rye
rye copied to clipboard
Tab completion: `rye run x` should yield completion to the called executable
Steps to Reproduce
-
rye run pyt <tab>
-
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 (d87583862 2023-05-23) platform: macos (aarch64) self-python: [email protected] symlink support: true
Stacktrace
No response
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)
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
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
.
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
.
I've written a number of CLI apps which do this, using the patterns in the scripts I linked here: https://github.com/mitsuhiko/rye/issues/213#issuecomment-1561176097 - 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
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?
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
I think if this ever gets fixed it might be possible to do something: https://github.com/clap-rs/clap/issues/1232
Closing this for now as I do not believe work here will actually take place.
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.
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?