Example #1
0
File: gen.go Project: knz/cockroach
func runGenManCmd(cmd *cobra.Command, args []string) error {
	info := build.GetInfo()
	header := &doc.GenManHeader{
		Section: "1",
		Manual:  "CockroachDB Manual",
		Source:  fmt.Sprintf("CockroachDB %s", info.Tag),
	}

	if !strings.HasSuffix(manPath, string(os.PathSeparator)) {
		manPath += string(os.PathSeparator)
	}

	if _, err := os.Stat(manPath); err != nil {
		if os.IsNotExist(err) {
			if err := os.MkdirAll(manPath, 0755); err != nil {
				return err
			}
		} else {
			return err
		}
	}

	if err := doc.GenManTree(cmd.Root(), header, manPath); err != nil {
		return err
	}

	// TODO(cdo): The man page generated by the cobra package doesn't include a list of commands, so
	// one has to notice the "See Also" section at the bottom of the page to know which commands
	// are supported. I'd like to make this better somehow.

	fmt.Println("Generated CockroachDB man pages in", manPath)
	return nil
}
Example #2
0
File: brag.go Project: garthk/nag
func genManTree(cmd *cobra.Command, dirname string) error {
	header := &doc.GenManHeader{
		Title:   "",  // auto-generate
		Section: "8", // system administration tools and procedures
		Source:  getPackagePath(),
	}
	return doc.GenManTree(cmd, header, dirname)
}
Example #3
0
func ExampleCommand_GenManTree() {
	cmd := &cobra.Command{
		Use:   "test",
		Short: "my test program",
	}
	header := &doc.GenManHeader{
		Title:   "MINE",
		Section: "3",
	}
	doc.GenManTree(cmd, header, "/tmp")
}
Example #4
0
func main() {
	header := &doc.GenManHeader{
		Title:   "rkt - App Container runtime",
		Section: "1",
	}

	err := doc.GenManTree(cmdRkt, header, "dist/manpages")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to generate the man pages: %v\n", err)
		os.Exit(254)
	}
}
Example #5
0
func (d *docsCmd) run() error {
	switch d.docTypeString {
	case "markdown", "mdown", "md":
		return doc.GenMarkdownTree(d.topCmd, d.dest)
	case "man":
		manHdr := &doc.GenManHeader{Title: "HELM", Section: "1"}
		return doc.GenManTree(d.topCmd, manHdr, d.dest)
	case "bash":
		return d.topCmd.GenBashCompletionFile(filepath.Join(d.dest, "completions.bash"))
	default:
		return fmt.Errorf("unknown doc type %q. Try 'markdown' or 'man'", d.docTypeString)
	}
}
Example #6
0
func runManPages(cmd *cobra.Command, args []string) (exit int) {
	outputDir := "./man/"

	os.MkdirAll(outputDir, 0755)

	header := &doc.GenManHeader{
		Title: "MINE",
		//Section string
		//Date    *time.Time
		//date    string
		//Source  string
		//Manual  string
	}
	err := doc.GenManTree(cmdAcbuild, header, outputDir)
	if err != nil {
		stderr("gen-man-pages: %v", err)
		return 1
	}

	stderr("man pages have been output to %s", outputDir)
	return 0
}
Example #7
0
		flagDocsManOutputDir = viper.GetString("man-output-dir")

		if flagDocsManOutputDir, err = absolutePath(
			flagDocsManOutputDir,
		); err != nil {
			return err
		}

		header := doc.GenManHeader{
			Section: "1",
			Manual:  "Fissile Manual",
			Source:  fmt.Sprintf("Fissile %s", version),
		}

		return doc.GenManTree(RootCmd, &header, flagDocsManOutputDir)
	},
}

func init() {
	docsCmd.AddCommand(docsManCmd)

	docsManCmd.PersistentFlags().StringP(
		"man-output-dir",
		"O",
		"./man",
		"Specifies a location where man pages will be generated.",
	)

	viper.BindPFlags(docsManCmd.PersistentFlags())
}
Example #8
0
	RunE: func(cmd *cobra.Command, args []string) error {
		header := &doc.GenManHeader{
			Section: "1",
			Manual:  "Hugo Manual",
			Source:  fmt.Sprintf("Hugo %s", helpers.HugoVersion()),
		}
		if !strings.HasSuffix(genmandir, helpers.FilePathSeparator) {
			genmandir += helpers.FilePathSeparator
		}
		if found, _ := helpers.Exists(genmandir, hugofs.Os()); !found {
			jww.FEEDBACK.Println("Directory", genmandir, "does not exist, creating...")
			hugofs.Os().MkdirAll(genmandir, 0777)
		}
		cmd.Root().DisableAutoGenTag = true

		jww.FEEDBACK.Println("Generating Hugo man pages in", genmandir, "...")
		doc.GenManTree(cmd.Root(), header, genmandir)

		jww.FEEDBACK.Println("Done.")

		return nil
	},
}

func init() {
	genmanCmd.PersistentFlags().StringVar(&genmandir, "dir", "man/", "the directory to write the man pages.")

	// For bash-completion
	genmanCmd.PersistentFlags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
}
Example #9
0
// Copyright © 2016 Geoff Holden <geoff@geoffholden.com>

package cmd

import (
	"github.com/spf13/cobra"
	"github.com/spf13/cobra/doc"
	"github.com/spf13/viper"
)

// manCmd represents the man command
var manCmd = &cobra.Command{
	Use:   "man",
	Short: "Generate man pages",
	Long:  `Generates a set of man pages for gowx`,
	Run: func(cmd *cobra.Command, args []string) {
		header := &doc.GenManHeader{
			Title:   "GOWX",
			Section: "3",
		}
		doc.GenManTree(RootCmd, header, viper.GetString("output"))
	},
}

func init() {
	docCmd.AddCommand(manCmd)
}