/
generate.go
45 lines (35 loc) · 1.09 KB
/
generate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 Joseph Lewis III <joseph@josephlewis.net>
// Licensed under the MIT License. See LICENSE file for full details.
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
var genmandir string
// genautocomplete Generate shell autocompletion script for Hugo
var genmanCmd = &cobra.Command{
Use: "man",
Short: "Generate man pages for Paraphrase",
Long: `This command creates man pages for Paraphrase.
By default, it creates them in "./man".`,
RunE: func(cmd *cobra.Command, args []string) error {
header := &doc.GenManHeader{
Section: "1",
Manual: "Paraphrase Manual",
Source: fmt.Sprintf("Paraphrase %s", Version),
}
if err := os.MkdirAll(genmandir, 0777); err != nil {
return err
}
fmt.Printf("Generaintg man pages in %s", genmandir)
fmt.Println()
doc.GenManTree(cmd.Root(), header, genmandir)
return nil
},
}
func init() {
genmanCmd.PersistentFlags().StringVar(&genmandir, "dir", "man/", "the directory to write the man pages.")
genmanCmd.PersistentFlags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
}