gitless-vcs / gitless

A simple version control system built on top of Git
https://gitless.com
MIT License
1.93k stars 106 forks source link

WIP: Add tab completion support with argcomplete #232

Closed xylix closed 4 years ago

xylix commented 4 years ago

Fixes #226

Implemented using argcomplete

Still needs automated install procedure. Screenshots of the tab completion in use, activated manually (in my personal fish shell, but argcomplete supports bash, zsh, fish and tzsh):

Screenshot 2020-03-31 at 13 00 24 Screenshot 2020-03-31 at 13 00 19

Which shells do we want to support automatic installation for? And what is the right place to hook a shell script completion installation? Offer it as an option (something like gl --install-completions) or as part of the pip / pyinstaller installation? https://stackoverflow.com/questions/58075926/python-argcomplete-and-pyinstaller Here's some info related to the technical implementation of automatically installing argcomplete completion in a pyinstaller packaged python application.

https://docs.pytest.org/en/latest/bash-completion.html pytest's documentation is a good example of documentation for manually enabling argcomplete completion.

spderosso commented 4 years ago

This is great, thanks. I like the idea of offering it as an option. I think it'll be easier than making it part of the pip/pyinstaller installation and it would work for those that use the binary release as well.

Which shells do we want to support automatic installation for?

Whichever shell you are using is fine. I might add support for zsh since that's the shell I am using right now. Once we have the --install-completions option there, it shouldn't be too hard for other people to add support for their favorite shell if they want to.

I was recently using the serverless CLI tool that had the following prompt:

Serverless: Would you like to setup a command line <tab> completion? Yes
Serverless: Which Shell do you use ? zsh
Serverless: We will install completion to ~/.zshrc, is it ok ? Yes

Command line <tab> completion was successfully setup. Make sure to reload your SHELL.

Perhaps we can do something similar when the user runs gl --install-completions:

> Would you like to setup a command line <tab> completion (Y/n)? Yes
> Which Shell do you use? zsh
> We will install completion to ~/.zshrc, is it ok (Y/n) ? Yes

Command line <tab> completion was successfully setup. Make sure to reload your SHELL.

What do you think?

xylix commented 4 years ago

The suggested CLI interface on gl --install-completions looks very good, I'll look into implementing something like that. It solves all of the annoying problems with installation for every type of release.