Generate man pages for kitten and all its sub-commands recursively

Fixes #6808
This commit is contained in:
Kovid Goyal
2023-11-11 17:09:23 +05:30
parent 0f2196357c
commit 70bc4f1033
22 changed files with 485 additions and 32 deletions

View File

@@ -20,7 +20,8 @@ func main() {
return
}
root := cli.NewRootCommand()
root.ShortDescription = "Fast, statically compiled implementations for various kittens (command line tools for use with kitty)"
root.ShortDescription = "Fast, statically compiled implementations of various kittens (command line tools for use with kitty)"
root.HelpText = "kitten serves as a launcher for running individual kittens. Each kitten can be run as :code:`kitten command`. The list of available kittens is given below."
root.Usage = "command [command options] [command args]"
root.Run = func(cmd *cli.Command, args []string) (int, error) {
cmd.ShowHelp()

View File

@@ -96,4 +96,29 @@ func KittyToolEntryPoints(root *cli.Command) {
return confirm_and_run_shebang(args)
},
})
// __generate_man_pages__
root.AddSubCommand(&cli.Command{
Name: "__generate_man_pages__",
Hidden: true,
OnlyArgsAllowed: true,
Run: func(cmd *cli.Command, args []string) (rc int, err error) {
q := root
if len(args) > 0 {
for _, scname := range args {
sc := q.FindSubCommand(scname)
if sc == nil {
return 1, fmt.Errorf("No sub command named: %s found", scname)
}
if err = sc.GenerateManPages(1, true); err != nil {
return 1, err
}
}
} else {
if err = q.GenerateManPages(1, false); err != nil {
rc = 1
}
}
return
},
})
}