Move kitty-tool __complete__ to use the new CLI framework

This commit is contained in:
Kovid Goyal
2022-09-23 12:30:41 +05:30
parent e7c14c78d0
commit 79cfc1e70a
6 changed files with 54 additions and 64 deletions

View File

@@ -8,8 +8,6 @@ import (
"io"
"os"
"github.com/spf13/cobra"
"kitty/tools/cli"
"kitty/tools/tty"
"kitty/tools/utils"
@@ -95,15 +93,13 @@ func main(args []string) error {
return err
}
func EntryPoint(tool_root *cobra.Command) *cobra.Command {
complete_command := cli.CreateCommand(&cobra.Command{
Use: "__complete__ output_type [shell state...]",
Short: "Generate completions for kitty commands",
Long: "Generate completion candidates for kitty commands. The command line is read from STDIN. output_type can be one of the supported shells or 'json' for JSON output.",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return main(args)
},
})
return complete_command
func EntryPoint(tool_root *cli.Command) {
c := tool_root.AddSubCommand("", "__complete__")
c.Usage = "output_type [shell state...]"
c.Hidden = true
c.ShortDescription = "Generate completions for kitty commands"
c.HelpText = "Generate completion candidates for kitty commands. The command line is read from STDIN. output_type can be one of the supported shells or 'json' for JSON output."
c.Run = func(cmd *cli.Command, args []string) (ret int, err error) {
return ret, main(args)
}
}