Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell completions support #877

Closed
zefr0x opened this issue May 29, 2023 · 3 comments · Fixed by #1054
Closed

Shell completions support #877

zefr0x opened this issue May 29, 2023 · 3 comments · Fixed by #1054
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@zefr0x
Copy link

zefr0x commented May 29, 2023

Summary 💡

What I mean is shell tab completions.

I think those shells should be supported taking priority into account:

  1. Bash
  2. Fish
  3. Zsh
  4. Elvish

Then maybe PowerShell for windows, but I don't think any one care 🙃.


I thought about using clap_complete to auto-generate completion scripts, but after a simple check in source code, we may need to make some changes that could have some complexity to generate them during build-time. However, for run-time this can be easily done, although some additional bloat have to be added to the binary to provide an option like --generate-completions in the CLI interface. It can be added as a feature for those who want to enable it before building the tool.

We may face a problem with auto-generation, like in git we may need dynamic completions, for example: display available branches or list of commits or staged files. clap_complete doesn't support dynamic completions as in clap-rs/clap#1232, but initially it may not be important for gix.

Motivation 🔦

It will make using gix easy and more productive.

@zefr0x zefr0x added the enhancement New feature or request label May 29, 2023
@kalkin
Copy link
Contributor

kalkin commented May 29, 2023

The issue with clap_complete is that you can't define your own completion types and compeltion code. It is very limited. You can't e.g. complete any git hashes.

@zefr0x
Copy link
Author

zefr0x commented May 29, 2023

We have four choices:

  1. Use limited clap_complete and wait for Dynamic completion support clap-rs/clap#1232.
  2. Use clap_complete to create initial base then add dynamic parts manually.
  3. Use git shell completions as a base.
  4. Build every thing from bare metal manually.

@Byron
Copy link
Member

Byron commented May 29, 2023

Thanks for bringing this up! Fix gix, as a development tool, I personally have no need for completions or if they happen anything fancy in that, but there is nothing wrong with having more than nothing if the maintenance costs are low. Thus, here I clearly prefer clap_complete as it's probably fully automatic, and that's what I remember from the time or two I used it.

For ein, one day I'd expect it to have the best-possible completions, but it's not quite there yet and it's unclear when that will happen. Maybe by that time, the Dynamic completion support is already available for clap.

In short, let's stick to what's basically free and live with the shortcomings of clap_complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants