by woodruffw · 9y ago · 0 comments
I've been looking for something like this for quite a while. There's compleat [1], but it doesn't seem to allow you to "compile" completions down to bash or zsh - you have to keep compleat (and therefore the whole Haskell stack) on your system.
Of course, none of this would be a problem if there was a standard "--complete <shell>" flag. I ended up doing something a bit like that on a recent project [2] to avoid editing my completion scripts every time I added a new subcommand or flag to a utility.
[1]: https://github.com/mbrubeck/compleat
[2]: https://github.com/woodruffw/kbsecret/blob/master/completion...
Only zsh support at the moment but would like to add bash support when I get some more time to spend on it. I find zsh completion far more powerful and easier to work with.
There is also a nodejs runtime library[1] for parsing arguments from the descriptor and some basic plugins. Later I would like to add runtime libraries for other languages :)
I'm a bash user, but I can't blame you ;)
> Of course, none of this would be a problem if there was a standard "--complete <shell>" flag.
PowerShell has interesting (if not very applicable to unix) approach: cmdlet parameters have some standard annotations attached that can be queried with reflection
Yeah, I think that's a tremendously useful feature. The status quo on unix of having 3-4 different program related files (man/info page, shell completions, i18n files) could really cleanly be replaced via a few standardized flags and pipe compositions. Take for example `man`:
man() { ${1} --man | less }
That's not feature-complete, of course, but IMO that's even more unixy than a bunch of out-of-sync /usr/share clutter.