-
Notifications
You must be signed in to change notification settings - Fork 137
/
doc.go
56 lines (51 loc) · 1.41 KB
/
doc.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
46
47
48
49
50
51
52
53
54
55
56
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
// docCmdGroup represents the doc command
var docCmdGroup = &cobra.Command{
Use: "doc <command>",
Short: "Print the documentation",
Long: "Print the documentation about the usage of cozy-stack in command-line",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Usage()
},
}
var manDocCmd = &cobra.Command{
Use: "man <directory>",
Short: "Print the manpages of cozy-stack",
Long: `Print the manual pages for using cozy-stack in command-line`,
Example: `$ mkdir -p ~/share/man
$ export MANPATH=~/share/man:$MANPATH
$ cozy-stack doc man ~/share/man
$ man cozy-stack`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return cmd.Usage()
}
header := &doc.GenManHeader{
Title: "COZY-STACK",
Section: "1",
}
return doc.GenManTree(RootCmd, header, args[0])
},
}
var markdownDocCmd = &cobra.Command{
Use: "markdown <directory>",
Short: "Print the documentation of cozy-stack as markdown",
Example: `$ cozy-stack doc markdown docs/cli`,
RunE: func(cmd *cobra.Command, args []string) error {
directory := "./docs/cli/"
if len(args) == 1 {
directory = args[0]
}
RootCmd.DisableAutoGenTag = true
return doc.GenMarkdownTree(RootCmd, directory)
},
}
func init() {
docCmdGroup.AddCommand(manDocCmd)
docCmdGroup.AddCommand(markdownDocCmd)
RootCmd.AddCommand(docCmdGroup)
}