2022-12-30 05:02:10 +03:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
mcobra "github.com/muesli/mango-cobra"
|
|
|
|
"github.com/muesli/roff"
|
|
|
|
"github.com/spf13/cobra"
|
2023-11-20 04:06:36 +03:00
|
|
|
|
|
|
|
"github.com/neilotoole/sq/cli/run"
|
2022-12-30 05:02:10 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-04-01 11:38:32 +03:00
|
|
|
func execGenerateMan(cmd *cobra.Command, _ []string) error {
|
2023-05-19 17:24:18 +03:00
|
|
|
ru := run.FromContext(cmd.Context())
|
2022-12-30 05:02:10 +03:00
|
|
|
manPage, err := mcobra.NewManPage(1, cmd.Root())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-05-19 17:24:18 +03:00
|
|
|
_, err = fmt.Fprint(ru.Out, manPage.Build(roff.NewDocument()))
|
2022-12-30 05:02:10 +03:00
|
|
|
return err
|
|
|
|
}
|