sq/cli/cmd_man.go
Neil O'Toole d9693bde17
Feature/manpages (#136)
* manpage support

* Polish up man work

* Set DisableAutoGenTag=true for all commands

* Set DisableAutoGenTag=true for root cmd

* CHANGELOG
2022-12-29 19:02:10 -07:00

35 lines
718 B
Go

package cli
import (
"fmt"
mcobra "github.com/muesli/mango-cobra"
"github.com/muesli/roff"
"github.com/spf13/cobra"
)
func newManCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "man",
Short: "Generate man pages",
SilenceUsage: true,
DisableFlagsInUseLine: true,
Hidden: true,
Args: cobra.NoArgs,
RunE: execGenerateMan,
}
return cmd
}
func execGenerateMan(cmd *cobra.Command, args []string) error {
rc := RunContextFrom(cmd.Context())
manPage, err := mcobra.NewManPage(1, cmd.Root())
if err != nil {
return err
}
_, err = fmt.Fprint(rc.Out, manPage.Build(roff.NewDocument()))
return err
}