How to create task's arguments autocompletion?
I have found no answer to the question in title in documentation nor GitHub issues nor PRs. Is it possible to do something like that at all and if yes, could you please point me to documentation, source code or anything which can explain how to archive task arguments completion?
Below is a long explanation with example of what I would like to be able to do.
Let's say I created a task in my justfile with name task-a which accepts one argument with values x, y, z.
At the moment even if I setup auto completions for just (i.e. with source <(~/.cargo/bin/just --completions bash) command in ~/.bashrc) I wasn't able to type just task-a press <Tab> and get auto completion suggestions for x, y, z. Or when I type just task-a w where w if first letter of x value and then press <Tab> I would like to get completion to the full value of x.
Another example of this could be when I have task-b which accepts one argument which is a list (or filtered list) of files in a specific project directory. Then typing just task-b some-fi and then <Tab> I would get a completion to just task-b some-file-name where some-file-name is a name of the file existing somewhere and implementation of task-b define where to find that file. In this case I don't assume just be smart enough to understand implementation of task-b I just want to explain (i.e. provide a path or mask to files) which can be used as potential variants for auto completion.
And thank you for the nice task runner! I really enjoy using it and extend my set of tasks almost every day!
I was looking for something similar recently, did you found anything till now?
No, I am still waiting for answers preferably from maintainers of the project. Meanwhile I started to look how it can be done. I think if there is nothing out there I will try to implement it and submit PR. But definitely it'll take a bit of time, but I hope to be able to do it during next month of so.
@Animeshz You can also upvote my question on StackOverflow may be somebody notice it there.
This could be implemented in just itself if the arguments were typed (debate-able if that should be in scope though).
It would definitely be nice to improve autocompletion here, probably with type hints which say things like "this argument is a path". Improving autocompletion probably won't happen until clap adds support for dynamic auto-completion which invokes just itself to figure out what the completions are. Our current approach of using generated autocomplete scripts which we then patch is too fragile to add new features to.
@casey What if we can generate scripts to call back to just with parameters for auto-completion? WDYT? Would you accept such PR or a prototype to further deeper understanding the feature and its implementation path?
I'm really hesitant to add explicit support for this to just. My experience with completion scripts has been that they're hard to write, hard to test, and break mysteriously, so I'd really like to avoid doing it ourselves and instead would like to lean on clap.
Looking at https://github.com/clap-rs/clap/blob/master/clap_complete/CHANGELOG.md
It seems clap_complete has supported dynamic completion. @casey