benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
410 stars 43 forks source link

Autocomplete commands #55

Open benthayer opened 4 years ago

benthayer commented 4 years ago

In bash, you can autocomplete commands so that you can hit tab when writing git gud load int and it'll fill it in with git gud load intro.

@e-leclercq is currently working on this.

benthayer commented 4 years ago

@e-leclercq Are you still interested in this?

sahansk2 commented 4 years ago

Just a comment on possible solutions...

The way that argcomplete works is that it runs the script up to a certain function call, and then returns the bash completions, more or less. So, it ends up being the case that bash completion feels slow and laggy.

An alternative that we should look into is the use of completions, which generates bash/zsh/fish completion from a YAML file. It also has a Python API, so we could have a make_completion.py to generate it like how we have a make_level.py. https://github.com/pwwang/completions

benthayer commented 3 years ago

completions seems like it would work, but I want to make sure that we actually have autocompletion for every command that we can run so we don't get confused when adding it later. Do you think we could make a script to generate the yaml from the parser defined in GitGud.__init__?

sahansk2 commented 3 years ago

A make_completion.py definitely seems possible, just iterate over command_dict and all_skills and whatnot. Might be a fun little Hacktoberfest project, too.

benthayer commented 3 years ago

Let's leave it open to whoever wants to tackle this

sahansk2 commented 3 years ago

Leaving this here in case it's relevant, since we're invoking with git gud and not git-gud: https://stackoverflow.com/questions/41307313/custom-git-command-autocompletion