2022-01-18 15:17:52 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2022-05-07 01:38:50 +02:00
|
|
|
mcoral "github.com/muesli/mango-cobra"
|
2022-01-18 15:17:52 +02:00
|
|
|
"github.com/muesli/roff"
|
2022-05-07 01:38:50 +02:00
|
|
|
"github.com/spf13/cobra"
|
2022-01-18 15:17:52 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type manCmd struct {
|
2022-05-07 01:38:50 +02:00
|
|
|
cmd *cobra.Command
|
2022-01-18 15:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func newManCmd() *manCmd {
|
|
|
|
root := &manCmd{}
|
2022-05-07 01:38:50 +02:00
|
|
|
cmd := &cobra.Command{
|
2022-01-18 15:17:52 +02:00
|
|
|
Use: "man",
|
|
|
|
Short: "Generates GoReleaser's command line manpages",
|
|
|
|
SilenceUsage: true,
|
|
|
|
DisableFlagsInUseLine: true,
|
|
|
|
Hidden: true,
|
2022-05-07 01:38:50 +02:00
|
|
|
Args: cobra.NoArgs,
|
2023-06-06 05:21:17 +02:00
|
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
2022-05-07 01:38:50 +02:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-02-04 21:31:19 +02:00
|
|
|
manPage, err := mcoral.NewManPage(1, root.cmd.Root())
|
2022-01-18 15:17:52 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument()))
|
|
|
|
return err
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
root.cmd = cmd
|
|
|
|
return root
|
|
|
|
}
|