The sound distributed version control system

#132 git-style command completion

Opened by loewenheim on November 28, 2020
loewenheim on November 28, 2020

In git, if you type e.g. git switch and hit Tab, you will get a list of all your branches. I don’t know how this kind of completion works, but it would be very nice to have.

arijid79 on November 29, 2020

This would have been a very nice addition. Although this cannot be currently implemented due to Clap not having an implementation of generating completions from structs. Though this is possible with the builder pattern

loewenheim on November 29, 2020

To be honest I don’t understand how clap would help here. At the time I want to see the completion, I’m still entering a line in the CLI, so the program hasn’t started yet.

arijid79 on November 29, 2020

A clap app has the function generate_completions to output auto completions for a specific shell into a file. This file is loaded by the shell to provide the completions. The problem with our implementation using structs is that it does not have such a method

loewenheim on November 29, 2020

No, I get that, but I don’t see how clap can generate completions for runtime information like what channels the current repo has.

danieleades on November 30, 2020


loewenheim on November 30, 2020

Wow, TIL. Thanks for the links!

pksunkara on November 30, 2020

Clap maintainer here, what’s the issue with generating completions from structs? Opts::into_app() should give you the built clap::App

arijid79 on November 30, 2020

Oh Thank you very much. I didn’t knew about the into_app() method

marians on December 3, 2020

So, what’s the way to go forward here? I would be willing to help with zsh completions.