go-arg
go-arg copied to clipboard
Completion support
I love the design of this library. However I could not find any information about generating completion scripts from the reflected CLI. This would be a fantastic addition!
Oh this would be great! I will likely look into this in the near future.
Here is a library that sets up a separate binary that provides completion support for the primary binary: https://github.com/posener/complete/tree/master
Ultimately, completions are installed into bash by appending a complete -C command to .bashrc: https://github.com/posener/complete/blob/master/install/bash.go#L36
Here is how it looks for the go build system: https://github.com/posener/complete/blob/05b68ffc813dd10c420993cb1cf927b346c057b8/gocomplete/complete.go
I've seen tools add an optional subcommand like app generate-completions that is automatically derived by the CLI library, similar to how --help is derived automatically.
Tagging as planned for v2