Start work on readline completions

This commit is contained in:
Kovid Goyal 2022-11-10 15:35:36 +05:30
parent f919efcd42
commit 7c23536bfe
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
6 changed files with 125 additions and 1 deletions

View file

@ -51,6 +51,14 @@ func RegisterExeForCompletion(x func(root *Command)) {
registered_exes = append(registered_exes, x)
}
func CompletionsForArgv(argv []string) *Completions {
var root = NewRootCommand()
for _, re := range registered_exes {
re(root)
}
return root.GetCompletions(argv, init_completions["json"])
}
func GenerateCompletions(args []string) error {
output_type := "json"
if len(args) > 0 {