Add shtab to third-party contrib list - #3793
Conversation
|
Could you explain what this is doing? It seems like it's trying to turn Click into argparse, removing all dynamic behavior and non-argparse-compatible behavior. Click and its shell completions are deliberately very customizable, it's not clear how this is supported. I don't think the basic description "speed up tab completion scripts" is accurate enough to capture the tradeoff. |
|
Under-the-hood, a Click's completions are currently unusably slow for complex apps, and it's not always desirable to move everything to lazy imports purely to make click's completions faster. Using The speedup feels noticeable even with the simple examples in the table above. |
Adds
shtabto https://click.palletsprojects.com/en/stable/contrib/#third-party-projects (sorted by stars).shtab.clickspeeds upclick's tab completion (particularly noticeable for complex apps) and adds support for more shells natively (currentlybash,zsh,fish,tcsh,pwsh,powershell).Note
click's_APP_COMPLETE=bash_source appcreates a script which calls_APP_COMPLETE=bash_complete appon every TAB press, whileshtab.clickhas the opposite approach - completions a pre-generated by default, and dynamic completions must be explicitly requested via e.g.shtab.cmd.Existing projects are supported without any source code changes, e.g.:
eval "$(_DOITLIVE_COMPLETE=bash_source doitlive)"eval "$(shtab -u doitlive.cli.cli --prog doitlive)"_ZENODO_GET_COMPLETE=zsh_source zenodo_get > _zenodo_getshtab -u zenodo_get.zget.cli --prog zenodo_get -s zsh > _zenodo_get_SQLITE_UTILS_COMPLETE=fish_source sqlite-utils | sourceshtab -u sqlite_utils.cli.cli --prog sqlite-utils -s fish | source