github.com/windmeup/goreleaser@v1.21.95/cmd/man.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	mcoral "github.com/muesli/mango-cobra"
     8  	"github.com/muesli/roff"
     9  	"github.com/spf13/cobra"
    10  )
    11  
    12  type manCmd struct {
    13  	cmd *cobra.Command
    14  }
    15  
    16  func newManCmd() *manCmd {
    17  	root := &manCmd{}
    18  	cmd := &cobra.Command{
    19  		Use:                   "man",
    20  		Short:                 "Generates GoReleaser's command line manpages",
    21  		SilenceUsage:          true,
    22  		DisableFlagsInUseLine: true,
    23  		Hidden:                true,
    24  		Args:                  cobra.NoArgs,
    25  		ValidArgsFunction:     cobra.NoFileCompletions,
    26  		RunE: func(cmd *cobra.Command, args []string) error {
    27  			manPage, err := mcoral.NewManPage(1, root.cmd.Root())
    28  			if err != nil {
    29  				return err
    30  			}
    31  
    32  			_, err = fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument()))
    33  			return err
    34  		},
    35  	}
    36  
    37  	root.cmd = cmd
    38  	return root
    39  }