mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-23 21:23:25 +00:00
parent
09379e893e
commit
50b5d0af29
1 changed files with 17 additions and 2 deletions
|
@ -2,12 +2,15 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
|
"github.com/spf13/hugo/hugofs"
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var genmandir string
|
||||||
var genmanCmd = &cobra.Command{
|
var genmanCmd = &cobra.Command{
|
||||||
Use: "man",
|
Use: "man",
|
||||||
Short: "Generate man pages for the Hugo CLI",
|
Short: "Generate man pages for the Hugo CLI",
|
||||||
|
@ -16,15 +19,27 @@ command-line interface. By default, it creates the man page files
|
||||||
in the "man" directory under the current directory.`,
|
in the "man" directory under the current directory.`,
|
||||||
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
genmandir := "man/"
|
|
||||||
cmd.Root().DisableAutoGenTag = true
|
|
||||||
header := &cobra.GenManHeader{
|
header := &cobra.GenManHeader{
|
||||||
Section: "1",
|
Section: "1",
|
||||||
Manual: "Hugo Manual",
|
Manual: "Hugo Manual",
|
||||||
Source: fmt.Sprintf("Hugo %s", helpers.HugoVersion()),
|
Source: fmt.Sprintf("Hugo %s", helpers.HugoVersion()),
|
||||||
}
|
}
|
||||||
|
if !strings.HasSuffix(genmandir, helpers.FilePathSeparator) {
|
||||||
|
genmandir += helpers.FilePathSeparator
|
||||||
|
}
|
||||||
|
if found, _ := helpers.Exists(genmandir, hugofs.OsFs); !found {
|
||||||
|
jww.FEEDBACK.Println("Directory", genmandir, "does not exist, creating...")
|
||||||
|
hugofs.OsFs.MkdirAll(genmandir, 0777)
|
||||||
|
}
|
||||||
|
cmd.Root().DisableAutoGenTag = true
|
||||||
|
|
||||||
jww.FEEDBACK.Println("Generating Hugo man pages in", genmandir, "...")
|
jww.FEEDBACK.Println("Generating Hugo man pages in", genmandir, "...")
|
||||||
cmd.Root().GenManTree(header, genmandir)
|
cmd.Root().GenManTree(header, genmandir)
|
||||||
|
|
||||||
jww.FEEDBACK.Println("Done.")
|
jww.FEEDBACK.Println("Done.")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
genmanCmd.PersistentFlags().StringVar(&genmandir, "dir", "man/", "the directory to write the man pages.")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue