Add commands/genman.go to autogenerate man pages

Fixes #1369
This commit is contained in:
Anthony Fok 2015-11-22 09:19:54 -07:00 committed by Bjørn Erik Pedersen
parent 8727475596
commit 098a0c819a
2 changed files with 31 additions and 0 deletions

30
commands/genman.go Normal file
View File

@ -0,0 +1,30 @@
package commands
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/hugo/helpers"
jww "github.com/spf13/jwalterweatherman"
)
var genmanCmd = &cobra.Command{
Use: "genman",
Short: "Generate man pages for the Hugo CLI",
Long: `This command automatically generates up-to-date man pages of Hugo's
command-line interface. By default, it creates the man page files
in the "man" directory under the current directory.`,
Run: func(cmd *cobra.Command, args []string) {
genmandir := "man/"
cmd.Root().DisableAutoGenTag = true
header := &cobra.GenManHeader{
Section: "1",
Manual: "Hugo Manual",
Source: fmt.Sprintf("Hugo %s", helpers.HugoVersion()),
}
jww.FEEDBACK.Println("Generating Hugo man pages in", genmandir, "...")
cmd.Root().GenManTree(header, genmandir)
jww.FEEDBACK.Println("Done.")
},
}

View File

@ -88,6 +88,7 @@ func AddCommands() {
HugoCmd.AddCommand(undraftCmd)
HugoCmd.AddCommand(genautocompleteCmd)
HugoCmd.AddCommand(gendocCmd)
HugoCmd.AddCommand(genmanCmd)
HugoCmd.AddCommand(importCmd)
}