Ensure auto-generated entries such as --help are present for completion by calling Validate()

This commit is contained in:
Kovid Goyal 2022-11-16 18:05:27 +05:30
parent 81916d0f02
commit e31587ec1e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 0 deletions

View File

@ -88,6 +88,7 @@ func GenerateCompletions(args []string) error {
re(root)
}
root.Validate()
all_completions := make([]*Completions, 0, 1)
for _, argv := range all_argv {
all_completions = append(all_completions, root.GetCompletions(argv, init_completions[output_type]))

View File

@ -186,6 +186,7 @@ func completions(before_cursor, after_cursor string) (ans *cli.Completions) {
root := cli.NewRootCommand()
c := root.AddSubCommand(&cli.Command{Name: "kitty-tool"})
EntryPoint(c)
root.Validate()
ans = root.GetCompletions(argv, nil)
ans.CurrentWordIdx = position_of_last_arg - len(prefix)
return

View File

@ -12,6 +12,8 @@ import (
var _ = fmt.Print
func KittyToolEntryPoints(root *cli.Command) {
root.Add(cli.OptionSpec{
Name: "--version", Type: "bool-set", Help: "The current kitty version."})
// @
at.EntryPoint(root)
// update-self