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
Add support for generating shell completions #223
Comments
That would be great! Is there any downside to doing both? It seems like it would be useful for distros if there was a completions file in the tarball that they could copy, and useful for end users that they can generate the completions file and use it no matter where they got |
This would be useful. However clap seems only to be able to generate completions for static things like options and their known values. To be useful, completion should also work on dynamic values like recipes from the current |
@siiptuo, good point. Let's start with generated ones and then add support for completing recipes for the current |
Maybe support of https://github.com/scop/bash-completion can be added first? Looks like the make completion can be reused, but doesn't work after a few attempts 😳 |
if you use o-my-zsh, following follow steps:
|
@linux-china doesnt work for me.
|
@timglabisch please make sure you use completion with justfile present in current directory. https://github.com/linux-china/oh-my-zsh/tree/master/plugins/just . I submitted a PR to oh-my-zsh for approve, and no response now. |
For fish shell the completion of recipe names is awfully trivial.
complete -c just -a (just --summary) |
for simple recipe completion this worked for me using bash4 and bash completions
|
It's not working tho. I got same error as timglabisch got. |
Depending on your setup, you may need to wrap it in a function. Here's mine: In
In
|
Tested with latest In fpath=($HOME/.zsh/completion $fpath)
autoload -Uz compinit
compinit -u In #compdef _just just
#autoload
_just () {
local -a subcmds
subcmds=($(just --summary))
_describe 'command' subcmds
}
_just "$@" |
@peterkc You made my day! Thanks! |
I've added the following code to if [ -f justfile ]; then
complete -W "`just --summary`" just
fi
# ex: ts=4 sw=4 et filetype=sh |
Your micro completions script are nice but they do not allow to complete just options... |
Year, they are just a workaround. So it'd be great if just can have some completion files that ships along it. |
I made a bash completion script that supposedly works for 0.5.4. See https://github.com/gotcha/just-bash-completion FTR, this is my first attempt at a completion script so any comments are welcome. |
Completion plugin for ohmyzsh: https://gist.github.com/un-def/ee696955bf0fb85e7cf2fc32f26eaa34 Thanks to @peterkc #223 (comment) |
Thanks so much to everyone who has worked on completions! If there are additional features in just that would help make completions better (like printing out recipes in a different format, etc) do let me know! Also, would it make sense to move or mirror the completion plug-ins into the just repository itself, so that they're more easily discoverable? They could also be included in the release tarballs, and would also be available for downstream packagers, like Homebrew et al. I don't have a lot of experience with how shell completion scripts are developed and distributed, so, for example, I don't know if it's more common for them to be packaged with the app, or packaged with the shell. (I.e. if the completion scripts should be bundled with just, or if it's better for them to be bundled with shell, as is the case with, for example, fish.) |
@casey I know nothing about completion scripts distribution. Nevertheless, I am totally fine with the idea of moving the bash completion script I did to your repo. |
My thinking is that if the completion scripts are distributed with the shell, then they might not be in sync with the latest version of just, but if they're distributed with just, then they might not be in sync with the latest version of the shell. However, it seems like a discoverability win for users if they're available in the Just repository. |
@casey After a quick search in the repo of Afaik, aside from shipping the completion files, using a completion subcommand or generating completion file from |
I just landed #572, which adds a The scripts are incomplete, however. They were generated with Clap, which is the argument parsing library that Just uses. As such, they don't support completing recipe names ( |
@heyrict Thanks for the info! If cargo ships completion files in their repo, then it's probably safe for Just too as well :P |
PS I opened #573 to track adding recipes to the shell completion scripts. |
I think the only thing left to do is to modify the completions generated with the |
clap
supports generating shell completions either at buildtime or at runtime. It would be helpful to add them. I'm willing to do the work on it, but I wanted to ask if you would prefer having acompletions
option to generate them at runtime, or a build script to generate them at compile time?The text was updated successfully, but these errors were encountered: