Start work on readline completions

This commit is contained in:
Kovid Goyal
2022-11-10 15:35:36 +05:30
parent f919efcd42
commit 7c23536bfe
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 {