3 ms·
Writing shell completions is a surprisingly tricky - especially for larger CLI tools or when you want to provide more advanced suggestions. Everything has to be
by mschrage 5y ago
Writing shell completions is a surprisingly tricky - especially for larger CLI tools or when you want to provide more advanced suggestions. Everything has to be done imperatively, usually as a shell script! It can get hairy quickly.
As a point of comparison, see the difference between the git completions written in bash [1] vs the declarative equivalent [2].
[1] https://github.com/git/git/blob/master/contrib/completion/git-completion.bash https://github.com/git/git/blob/master/contrib/completion/gi...
[2] https://github.com/withfig/autocomplete/blob/master/src/git.ts https://github.com/withfig/autocomplete/blob/master/src/git....
- pastage 5y agoGreat that someone is thinking about this, doesn't seem very usefull though, it requires MacOS. But the bash one has been there since the beginning, so you are comparing a project that seems to be created in 2021 without any need for backward compatibilty with one that has grown organically for 15 years.
- nrclark 5y agoIt doesn't have to be pure shell. I've written a few tools that have built-in completion helpers. All their completion scripts have to do is run the tool with the right environment variables, and return the results. That's also how autocompletion works with Python's excellent Click library.