-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I've been trying to review #1403 (comment), which adds type-based completions, and it made me realize just how messy completion is, both within Click and with how the shells implement and document their systems.
Right now, a project would provide a much better user experience right now by providing their own handwritten completion script rather than using Click's. Due to its dynamic nature, Click probably won't be able to generate an equivalent script, but I think we can at least get closer.
Because Click only returns completion values, the shell has no metadata about what's actually being completed. This means we keep having to re-implement things that the shell should be doing, such as escaping special characters, adding spaces (except for directories), sorting, etc. And if the user wants to provide their own completions, they have to remember to do all that too.
There's no reason we just have to return completions. We already support returning descriptions, presumably we could extend that more. Wouldn't it be cool if Click could indicate to the completion script that it should use other functions that Bash or ZSH provide?