Open cgsdev0 opened 5 months ago
@cgsdev0 assigned 💞
@cgsdev0 How does shipping shell completions work?
Is it like a man page where you have to put a file in some os-dependent place on disk?
(I'm really asking: how does this ticket impact our install process? would we need to integrate with package managers?)
i don't really know tbh
we can try to find some prior art
got curious, did some digging.
shells expect to find a "completion file", which is a shell script that invokes that shell's "complete" builtin a lot of times, in a particular os-specific shell-specific folder.
one prior art
the cobra library (very fancy go framework for cli tools) adds a command to your CLI which prints a completion file for a given shell:
$tool completion --shell {bash|fish|zsh|powershell}
A user can then run something like this to install the completion:
$tool completion --shell fish > "(pkg-config --variable completionsdir fish)/$tool.fish"
Their pacakge-manager configurations work the same way, eg Macports
another prior art is https://github.com/posener/complete/tree/master, which seems a teensy bit ramshackle (the api is poorly considered, it installs completions to the wrong place, the installed completion prints a stacktrace when I hit tab to execute it) but it does have some cute nuggets:
that second bit is particularly interesting: it suggests that we can, eg, parse a local taskfile with our regular go taskfile parsing to generate completions on-the-fly
that second bit is particularly interesting: it suggests that we can, eg, parse a local taskfile with our regular go taskfile parsing to generate completions on-the-fly
yeah this is the main feature i had in mind
i will probably start with just writing the completions file, and then we can worry about how to get it installed 👍
sounds cool; lookin' forward to it
if you assign this to me ill do it