1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
package main
import (
"errors"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
cli "github.com/lxc/incus/v6/internal/cmd"
)
type cmdManpage struct {
global *cmdGlobal
}
func (c *cmdManpage) command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = "manpage <target>"
cmd.Short = "Generate manpages for all commands"
cmd.Long = cli.FormatSection("Description",
`Generate manpages for all commands`)
cmd.Hidden = true
cmd.RunE = c.run
return cmd
}
func (c *cmdManpage) run(cmd *cobra.Command, args []string) error {
// Quick checks.
if len(args) != 1 {
_ = cmd.Help()
if len(args) == 0 {
return nil
}
return errors.New("Missing required arguments")
}
// Generate the manpages
header := &doc.GenManHeader{
Title: "Incus - Daemon",
Section: "1",
}
opts := doc.GenManTreeOptions{
Header: header,
Path: args[0],
CommandSeparator: ".",
}
_ = doc.GenManTreeFromOpts(c.global.cmd, opts)
return nil
}
|