| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Uses `argcomplete` to add basic completions to the cli.
|
sorry, don't really want to add a dependency for this |
Sorry, something went wrong.
|
also the strategy used by argcomplete is too slow to be useful, it adds ~200ms per <tab> press which is well past the noticeable "slowness" I believe the more correct way to do something like this would be to pregenerate completions as part of the packaging and provide those separately |
Sorry, something went wrong.
|
Thanks for the quick reply. In my opinion completions are pretty important for friendly, usable CLI tools. I understand pre-commit isn't first and foremost a CLI tool, but I found I missed completions when I was trying to remember how to install a commit-msg hook just now (typing -h is too much for me :)) I guess we could write completions by hand for the relatively small number of available commands and not need any new dependencies, but this is definitely the easiest and most integrated way to provide completions. |
Sorry, something went wrong.
|
it's not particularly difficult to generate completions scripts, here's some prior art: https://github.com/asottile/all-repos/blob/master/all_repos/complete.py Would expose some command like: eval "$(pre-commit complete)"which you could put in your rc file |
Sorry, something went wrong.
|
Just seen your followups, yep it's laggy (tbh I'm using WSL so I'm used to laggy terminals, didn't really notice...). I think the lag could be alleviated with a refactor to avoid importing before parsing CLIs, I've used this style of autocompletion before and it worked a charm. In any case, I don't really have the time to invest into writing anything substantial right now, shall I close this and open an issue about completions instead? |
Sorry, something went wrong.
|
yeah I don't really want to play the import whackamole game -- there's not a good reason to runtime-compute completions when we can generate them all statically |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uses argcomplete to trivially add basic completions to the cli.
This allows things like:
And
Which can be tab toggled through once the correct completions are registered (at least in fish, I didn't try other shells yet).
This is pretty basic (as might be expected from adding 2 simple lines of code!!!), it would be really nice to do a bit more, such as getting a list of the available hooks and completing pre-commit run <TAB> with them.
Also, at least with click CLIs, you should be able to get help messages showing up (in fish at least) which is nicer than this. Of course, this would require a rewrite of the parser code to use click...
Any opinions about this sort of functionality?