boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.67k stars 264 forks source link

[feature] shell completion #337

Open Freed-Wu opened 2 years ago

Freed-Wu commented 2 years ago

Now, scc has many command options. If it can provide shell completion (bash/zsh/fish/...), it will be more convenient to use. Thanks.

boyter commented 2 years ago

@Freed-Wu Do you have any details on how to achieve such a thing?

Freed-Wu commented 2 years ago

Maybe https://docs.rs/clap_complete/latest/clap_complete can be helpful?

Or that projects support completions (e.g. ripgrep, fd, exa, github-cli, etc) can be a reference.

boyter commented 2 years ago

Ah... thats what you mean. I think this is pretty easy https://jmtirado.net/shell-completion-with-cobra-and-go/

Freed-Wu commented 2 years ago

Great. Such as https://github.com/cli/cli/blob/cf4b73ff958b272cf3c9c0cf9351459f76b793a0/pkg/cmd/completion/completion.go?